{"action":"created","comment":{"url":"https://api.github.com/repos/mpc-hc/mpc-hc/pulls/comments/23496495","id":23496495,"diff_hunk":"@@ -0,0 +1,852 @@\n+﻿/*\n+ * (C) 2014-2015 see Authors.txt\n+ *\n+ * This file is part of MPC-HC.\n+ *\n+ * MPC-HC is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 3 of the License, or\n+ * (at your option) any later version.\n+ *\n+ * MPC-HC is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU General Public License\n+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.\n+ *\n+ */\n+\n+#include \"stdafx.h\"\n+#include \"SubtitlesProvider.h\"\n+#include \"MediaInfo/ThirdParty/tinyxml2/tinyxml2.h\"\n+using namespace tinyxml2;\n+\n+#include \"rapidjson/include/rapidjson/rapidjson.h\"\n+#include \"rapidjson/include/rapidjson/document.h\"\n+\n+/******************************************************************************\n+** Register providers\n+******************************************************************************/\n+void SubtitlesProviders::RegisterProviders()\n+{\n+    Register<OpenSubtitles>();\n+    Register<podnapisi>();\n+    Register<titlovi>();\n+    Register<SubDB>();\n+    Register<ysubs>();\n+}\n+\n+#define CheckAbortAndReturn() { if (IsAborting()) return SR_ABORTED; }\n+\n+/******************************************************************************\n+** OpenSubtitles\n+******************************************************************************/\n+\n+void OpenSubtitles::Initialize()\n+{\n+    xmlrpc = DEBUG_NEW XmlRpcClient(\"http://api.opensubtitles.org/xml-rpc\");\n+    if (xmlrpc) { xmlrpc->setIgnoreCertificateAuthority(); }\n+}\n+\n+void OpenSubtitles::Uninitialize()\n+{\n+    if (xmlrpc != nullptr) { delete xmlrpc; }\n+}\n+\n+SRESULT OpenSubtitles::Login(std::string& sUserName, std::string& sPassword)\n+{\n+    if (xmlrpc) {\n+        XmlRpcValue args, result;\n+        args[0] = sUserName;\n+        args[1] = sPassword;\n+        args[2] = \"en\";\n+        args[3] = UserAgent().c_str(); // Test with \"OSTestUserAgent\"\n+        if (!xmlrpc->execute(\"LogIn\", args, result)) { return SR_FAILED; }\n+        token = result[\"token\"];\n+    }\n+    return token.valid() ? SR_SUCCEEDED : SR_FAILED;","path":"src/mpc-hc/SubtitlesProvider.cpp","position":69,"original_position":69,"commit_id":"b9ea246dabf639af6a806d20b7a4e688970e0d75","original_commit_id":"b9ea246dabf639af6a806d20b7a4e688970e0d75","user":{"login":"ioannis-e","id":5904989,"avatar_url":"https://avatars.githubusercontent.com/u/5904989?v=3","gravatar_id":"","url":"https://api.github.com/users/ioannis-e","html_url":"https://github.com/ioannis-e","followers_url":"https://api.github.com/users/ioannis-e/followers","following_url":"https://api.github.com/users/ioannis-e/following{/other_user}","gists_url":"https://api.github.com/users/ioannis-e/gists{/gist_id}","starred_url":"https://api.github.com/users/ioannis-e/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ioannis-e/subscriptions","organizations_url":"https://api.github.com/users/ioannis-e/orgs","repos_url":"https://api.github.com/users/ioannis-e/repos","events_url":"https://api.github.com/users/ioannis-e/events{/privacy}","received_events_url":"https://api.github.com/users/ioannis-e/received_events","type":"User","site_admin":false},"body":"No m_nLoggedIn, checks if we are already logged in and its never called again.","created_at":"2015-01-24T14:00:35Z","updated_at":"2015-01-24T14:00:35Z","html_url":"https://github.com/mpc-hc/mpc-hc/pull/146#discussion_r23496495","pull_request_url":"https://api.github.com/repos/mpc-hc/mpc-hc/pulls/146","_links":{"self":{"href":"https://api.github.com/repos/mpc-hc/mpc-hc/pulls/comments/23496495"},"html":{"href":"https://github.com/mpc-hc/mpc-hc/pull/146#discussion_r23496495"},"pull_request":{"href":"https://api.github.com/repos/mpc-hc/mpc-hc/pulls/146"}}},"pull_request":{"url":"https://api.github.com/repos/mpc-hc/mpc-hc/pulls/146","id":27937914,"html_url":"https://github.com/mpc-hc/mpc-hc/pull/146","diff_url":"https://github.com/mpc-hc/mpc-hc/pull/146.diff","patch_url":"https://github.com/mpc-hc/mpc-hc/pull/146.patch","issue_url":"https://api.github.com/repos/mpc-hc/mpc-hc/issues/146","number":146,"state":"open","locked":false,"title":"feature/subtitles","user":{"login":"ioannis-e","id":5904989,"avatar_url":"https://avatars.githubusercontent.com/u/5904989?v=3","gravatar_id":"","url":"https://api.github.com/users/ioannis-e","html_url":"https://github.com/ioannis-e","followers_url":"https://api.github.com/users/ioannis-e/followers","following_url":"https://api.github.com/users/ioannis-e/following{/other_user}","gists_url":"https://api.github.com/users/ioannis-e/gists{/gist_id}","starred_url":"https://api.github.com/users/ioannis-e/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ioannis-e/subscriptions","organizations_url":"https://api.github.com/users/ioannis-e/orgs","repos_url":"https://api.github.com/users/ioannis-e/repos","events_url":"https://api.github.com/users/ioannis-e/events{/privacy}","received_events_url":"https://api.github.com/users/ioannis-e/received_events","type":"User","site_admin":false},"body":"continued from [here](https://github.com/mpc-hc/mpc-hc/pull/123)\r\n\r\nThe scope of this project is to rewrite the subtitles framework, in order to:\r\n- be able to support more subtitles providers both with or without an API.\r\n- limit requested subtitles to selected languages only instead of flooding the table with unwanted languages. \r\n- prioritize subtitles for hearing impaired where indicated\r\n- provide a framework to automatically search and download subtitles at the beginning of playback without user interaction by ranking the subtitles served by each provider, based on file name information, hearing impaired and language.\r\n- finally provide a framework to enable subtitles uploads to providers.\r\n\r\n_Auto download feature specification_\r\n```\r\nAll providers start searching simultaneusly and are allowed to download subtitles by order of completion.\r\nIf no langauages are selected in the language filter then the dialogbox appears and user can manually select a subtitle.\r\nif languages are selected, then subtitles will be automatically downloaded based on priority, ie.\r\nif none of the subtitles found have an adequate internal score, the dowload window is shown.\r\nSCENARIO 1\r\nif user has selected \"ell,eng\" then,\r\nif the first porvider that completes the search only serves \"eng\" it is entitled to download and activate \"eng\".\r\nif the second provider that completes the serach serves \"eng\" and \"ell\" it is entitled to download and activate only \"ell\" which has a higher priority.\r\nThe third etc providers will not be entitled to download or activate any subtitles as the highest priority language has been served.\r\nSCENARIO 2\r\nif user has selected \"ell,eng\" then,\r\nif the first porvider that completes the search serves both \"ell\" and \"eng\" it is entitled to download and activate only \"ell\", which has a higher priority.\r\nThe second etc providers to complete are not entitled to download or activate any subtitles as the highest priority language has been served.\r\n```\r\n_Status of project:_\r\n- [ ] Internationalization/translation for new strings\r\n\r\n\r\n*Current state of implementations:*\r\n\r\n| Provider  | Type | Search & Download  | Upload | Login |\r\n| :------------ | :---------------: | :-----: | :---------------: | :-----: |\r\n| OpenSubtitles | XML-RPC, hash    | Y | Y | Y |\r\n| SubDB | API, hash | Y | Y | N/A |\r\n| podnapisi | XML | Y | N | N |\r\n| titlovi | XML | Y | N | N |\r\n| ysubs | json | Y | N | N |\r\n\r\n\r\n_Visual aid:_\r\n\r\nOptions\r\n![image](https://cloud.githubusercontent.com/assets/5904989/3389203/0ca222ec-fc92-11e3-9c07-da651324ac77.png)\r\n\r\nDownload\r\n![image](https://cloud.githubusercontent.com/assets/5904989/3389319/834d27ce-fc93-11e3-9ce8-fd8bcc80c310.png)\r\n\r\nUpload\r\n![image](https://cloud.githubusercontent.com/assets/5904989/3389222/424d85f8-fc92-11e3-9c04-1f6a3297103a.png)\r\n\r\nContext menu\r\n![image](https://f.cloud.github.com/assets/5904989/1796029/dcef1040-6a4d-11e3-9db4-5a4d49149d92.png)\r\n\r\n\r\nDependencies included in PR:\r\n- [x] TimXmlRpc (http://sourceforge.net/projects/xmlrpcc4win/)\r\n- [x] minizip (part of zlib)\r\n- [x] rapidjson (https://github.com/miloyip/rapidjson)\r\n\r\nBuilds for test purposes - v1.7.7.216 (c4ed7b9):\r\n[x86](https://drive.google.com/file/d/0B_jV1CFl8NWlTlBub0lmV2xuWVU/edit?usp=sharing)\r\n[x64](https://drive.google.com/file/d/0B_jV1CFl8NWlV3ZlSjFpUmZsbm8/edit?usp=sharing)","created_at":"2015-01-23T16:54:38Z","updated_at":"2015-01-24T14:00:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"be2ab0981bd9fb270f7e7b2e0289e2aec5ec1abf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mpc-hc/mpc-hc/pulls/146/commits","review_comments_url":"https://api.github.com/repos/mpc-hc/mpc-hc/pulls/146/comments","review_comment_url":"https://api.github.com/repos/mpc-hc/mpc-hc/pulls/comments/{number}","comments_url":"https://api.github.com/repos/mpc-hc/mpc-hc/issues/146/comments","statuses_url":"https://api.github.com/repos/mpc-hc/mpc-hc/statuses/b9ea246dabf639af6a806d20b7a4e688970e0d75","head":{"label":"ioannis-e:feature/subtitles","ref":"feature/subtitles","sha":"b9ea246dabf639af6a806d20b7a4e688970e0d75","user":{"login":"ioannis-e","id":5904989,"avatar_url":"https://avatars.githubusercontent.com/u/5904989?v=3","gravatar_id":"","url":"https://api.github.com/users/ioannis-e","html_url":"https://github.com/ioannis-e","followers_url":"https://api.github.com/users/ioannis-e/followers","following_url":"https://api.github.com/users/ioannis-e/following{/other_user}","gists_url":"https://api.github.com/users/ioannis-e/gists{/gist_id}","starred_url":"https://api.github.com/users/ioannis-e/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ioannis-e/subscriptions","organizations_url":"https://api.github.com/users/ioannis-e/orgs","repos_url":"https://api.github.com/users/ioannis-e/repos","events_url":"https://api.github.com/users/ioannis-e/events{/privacy}","received_events_url":"https://api.github.com/users/ioannis-e/received_events","type":"User","site_admin":false},"repo":{"id":14744361,"name":"mpc-hc","full_name":"ioannis-e/mpc-hc","owner":{"login":"ioannis-e","id":5904989,"avatar_url":"https://avatars.githubusercontent.com/u/5904989?v=3","gravatar_id":"","url":"https://api.github.com/users/ioannis-e","html_url":"https://github.com/ioannis-e","followers_url":"https://api.github.com/users/ioannis-e/followers","following_url":"https://api.github.com/users/ioannis-e/following{/other_user}","gists_url":"https://api.github.com/users/ioannis-e/gists{/gist_id}","starred_url":"https://api.github.com/users/ioannis-e/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ioannis-e/subscriptions","organizations_url":"https://api.github.com/users/ioannis-e/orgs","repos_url":"https://api.github.com/users/ioannis-e/repos","events_url":"https://api.github.com/users/ioannis-e/events{/privacy}","received_events_url":"https://api.github.com/users/ioannis-e/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ioannis-e/mpc-hc","description":"Personal MPC-HC repository, force pushed after fetch and rebase on MPC-HC's main repository.","fork":true,"url":"https://api.github.com/repos/ioannis-e/mpc-hc","forks_url":"https://api.github.com/repos/ioannis-e/mpc-hc/forks","keys_url":"https://api.github.com/repos/ioannis-e/mpc-hc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ioannis-e/mpc-hc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ioannis-e/mpc-hc/teams","hooks_url":"https://api.github.com/repos/ioannis-e/mpc-hc/hooks","issue_events_url":"https://api.github.com/repos/ioannis-e/mpc-hc/issues/events{/number}","events_url":"https://api.github.com/repos/ioannis-e/mpc-hc/events","assignees_url":"https://api.github.com/repos/ioannis-e/mpc-hc/assignees{/user}","branches_url":"https://api.github.com/repos/ioannis-e/mpc-hc/branches{/branch}","tags_url":"https://api.github.com/repos/ioannis-e/mpc-hc/tags","blobs_url":"https://api.github.com/repos/ioannis-e/mpc-hc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ioannis-e/mpc-hc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ioannis-e/mpc-hc/git/refs{/sha}","trees_url":"https://api.github.com/repos/ioannis-e/mpc-hc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ioannis-e/mpc-hc/statuses/{sha}","languages_url":"https://api.github.com/repos/ioannis-e/mpc-hc/languages","stargazers_url":"https://api.github.com/repos/ioannis-e/mpc-hc/stargazers","contributors_url":"https://api.github.com/repos/ioannis-e/mpc-hc/contributors","subscribers_url":"https://api.github.com/repos/ioannis-e/mpc-hc/subscribers","subscription_url":"https://api.github.com/repos/ioannis-e/mpc-hc/subscription","commits_url":"https://api.github.com/repos/ioannis-e/mpc-hc/commits{/sha}","git_commits_url":"https://api.github.com/repos/ioannis-e/mpc-hc/git/commits{/sha}","comments_url":"https://api.github.com/repos/ioannis-e/mpc-hc/comments{/number}","issue_comment_url":"https://api.github.com/repos/ioannis-e/mpc-hc/issues/comments/{number}","contents_url":"https://api.github.com/repos/ioannis-e/mpc-hc/contents/{+path}","compare_url":"https://api.github.com/repos/ioannis-e/mpc-hc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ioannis-e/mpc-hc/merges","archive_url":"https://api.github.com/repos/ioannis-e/mpc-hc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ioannis-e/mpc-hc/downloads","issues_url":"https://api.github.com/repos/ioannis-e/mpc-hc/issues{/number}","pulls_url":"https://api.github.com/repos/ioannis-e/mpc-hc/pulls{/number}","milestones_url":"https://api.github.com/repos/ioannis-e/mpc-hc/milestones{/number}","notifications_url":"https://api.github.com/repos/ioannis-e/mpc-hc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ioannis-e/mpc-hc/labels{/name}","releases_url":"https://api.github.com/repos/ioannis-e/mpc-hc/releases{/id}","created_at":"2013-11-27T10:49:09Z","updated_at":"2015-01-23T16:34:09Z","pushed_at":"2015-01-24T10:38:46Z","git_url":"git://github.com/ioannis-e/mpc-hc.git","ssh_url":"git@github.com:ioannis-e/mpc-hc.git","clone_url":"https://github.com/ioannis-e/mpc-hc.git","svn_url":"https://github.com/ioannis-e/mpc-hc","homepage":"http://mpc-hc.org/","size":193945,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mpc-hc:develop","ref":"develop","sha":"9959753ef6d82787592de494f99dd888dcc5429c","user":{"login":"mpc-hc","id":1625629,"avatar_url":"https://avatars.githubusercontent.com/u/1625629?v=3","gravatar_id":"","url":"https://api.github.com/users/mpc-hc","html_url":"https://github.com/mpc-hc","followers_url":"https://api.github.com/users/mpc-hc/followers","following_url":"https://api.github.com/users/mpc-hc/following{/other_user}","gists_url":"https://api.github.com/users/mpc-hc/gists{/gist_id}","starred_url":"https://api.github.com/users/mpc-hc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpc-hc/subscriptions","organizations_url":"https://api.github.com/users/mpc-hc/orgs","repos_url":"https://api.github.com/users/mpc-hc/repos","events_url":"https://api.github.com/users/mpc-hc/events{/privacy}","received_events_url":"https://api.github.com/users/mpc-hc/received_events","type":"Organization","site_admin":false},"repo":{"id":5180577,"name":"mpc-hc","full_name":"mpc-hc/mpc-hc","owner":{"login":"mpc-hc","id":1625629,"avatar_url":"https://avatars.githubusercontent.com/u/1625629?v=3","gravatar_id":"","url":"https://api.github.com/users/mpc-hc","html_url":"https://github.com/mpc-hc","followers_url":"https://api.github.com/users/mpc-hc/followers","following_url":"https://api.github.com/users/mpc-hc/following{/other_user}","gists_url":"https://api.github.com/users/mpc-hc/gists{/gist_id}","starred_url":"https://api.github.com/users/mpc-hc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpc-hc/subscriptions","organizations_url":"https://api.github.com/users/mpc-hc/orgs","repos_url":"https://api.github.com/users/mpc-hc/repos","events_url":"https://api.github.com/users/mpc-hc/events{/privacy}","received_events_url":"https://api.github.com/users/mpc-hc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mpc-hc/mpc-hc","description":"MPC-HC's main repository.  For support use our Trac: https://trac.mpc-hc.org/","fork":false,"url":"https://api.github.com/repos/mpc-hc/mpc-hc","forks_url":"https://api.github.com/repos/mpc-hc/mpc-hc/forks","keys_url":"https://api.github.com/repos/mpc-hc/mpc-hc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mpc-hc/mpc-hc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mpc-hc/mpc-hc/teams","hooks_url":"https://api.github.com/repos/mpc-hc/mpc-hc/hooks","issue_events_url":"https://api.github.com/repos/mpc-hc/mpc-hc/issues/events{/number}","events_url":"https://api.github.com/repos/mpc-hc/mpc-hc/events","assignees_url":"https://api.github.com/repos/mpc-hc/mpc-hc/assignees{/user}","branches_url":"https://api.github.com/repos/mpc-hc/mpc-hc/branches{/branch}","tags_url":"https://api.github.com/repos/mpc-hc/mpc-hc/tags","blobs_url":"https://api.github.com/repos/mpc-hc/mpc-hc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mpc-hc/mpc-hc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mpc-hc/mpc-hc/git/refs{/sha}","trees_url":"https://api.github.com/repos/mpc-hc/mpc-hc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mpc-hc/mpc-hc/statuses/{sha}","languages_url":"https://api.github.com/repos/mpc-hc/mpc-hc/languages","stargazers_url":"https://api.github.com/repos/mpc-hc/mpc-hc/stargazers","contributors_url":"https://api.github.com/repos/mpc-hc/mpc-hc/contributors","subscribers_url":"https://api.github.com/repos/mpc-hc/mpc-hc/subscribers","subscription_url":"https://api.github.com/repos/mpc-hc/mpc-hc/subscription","commits_url":"https://api.github.com/repos/mpc-hc/mpc-hc/commits{/sha}","git_commits_url":"https://api.github.com/repos/mpc-hc/mpc-hc/git/commits{/sha}","comments_url":"https://api.github.com/repos/mpc-hc/mpc-hc/comments{/number}","issue_comment_url":"https://api.github.com/repos/mpc-hc/mpc-hc/issues/comments/{number}","contents_url":"https://api.github.com/repos/mpc-hc/mpc-hc/contents/{+path}","compare_url":"https://api.github.com/repos/mpc-hc/mpc-hc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mpc-hc/mpc-hc/merges","archive_url":"https://api.github.com/repos/mpc-hc/mpc-hc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mpc-hc/mpc-hc/downloads","issues_url":"https://api.github.com/repos/mpc-hc/mpc-hc/issues{/number}","pulls_url":"https://api.github.com/repos/mpc-hc/mpc-hc/pulls{/number}","milestones_url":"https://api.github.com/repos/mpc-hc/mpc-hc/milestones{/number}","notifications_url":"https://api.github.com/repos/mpc-hc/mpc-hc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mpc-hc/mpc-hc/labels{/name}","releases_url":"https://api.github.com/repos/mpc-hc/mpc-hc/releases{/id}","created_at":"2012-07-25T15:04:04Z","updated_at":"2015-01-23T00:10:43Z","pushed_at":"2015-01-22T22:30:02Z","git_url":"git://github.com/mpc-hc/mpc-hc.git","ssh_url":"git@github.com:mpc-hc/mpc-hc.git","clone_url":"https://github.com/mpc-hc/mpc-hc.git","svn_url":"https://github.com/mpc-hc/mpc-hc","homepage":"http://mpc-hc.org/","size":214841,"stargazers_count":532,"watchers_count":532,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":244,"mirror_url":null,"open_issues_count":9,"forks":244,"open_issues":9,"watchers":532,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/mpc-hc/mpc-hc/pulls/146"},"html":{"href":"https://github.com/mpc-hc/mpc-hc/pull/146"},"issue":{"href":"https://api.github.com/repos/mpc-hc/mpc-hc/issues/146"},"comments":{"href":"https://api.github.com/repos/mpc-hc/mpc-hc/issues/146/comments"},"review_comments":{"href":"https://api.github.com/repos/mpc-hc/mpc-hc/pulls/146/comments"},"review_comment":{"href":"https://api.github.com/repos/mpc-hc/mpc-hc/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/mpc-hc/mpc-hc/pulls/146/commits"},"statuses":{"href":"https://api.github.com/repos/mpc-hc/mpc-hc/statuses/b9ea246dabf639af6a806d20b7a4e688970e0d75"}}}}