{"action":"created","comment":{"url":"https://api.github.com/repos/Flexget/Flexget/pulls/comments/76532778","id":76532778,"diff_hunk":"@@ -0,0 +1,141 @@\n+from __future__ import unicode_literals, division, absolute_import\n+from builtins import *  # pylint: disable=unused-import, redefined-builtin\n+from past.utils import old_div\n+from future.moves.urllib.parse import urlencode, quote_plus\n+\n+import logging\n+\n+from flexget import plugin\n+from flexget.entry import Entry\n+from flexget.event import event\n+from flexget.utils.search import normalize_unicode\n+import feedparser\n+\n+__author__ = 'davst'\n+\n+log = logging.getLogger('jackett_torznab')\n+\n+\n+class Jackett_torznab(object):\n+    \"\"\"\n+    Jackett_torznab search plugin\n+    Based on the newznab plugin\n+    Provide a url or your website + apikey and a category\n+\n+    Config example::\n+\n+        Jackett_Torznab:\n+          url: \"http://website/api?apikey=xxxxxxxxxxxxxxxxxxxxxxxxxx&t=movie&extended=1\"\n+          website: https://website\n+          apikey: xxxxxxxxxxxxxxxxxxxxxxxxxx\n+          category: movie\n+\n+    Category is any of: movie, tvsearch, search\n+    \"\"\"\n+\n+    schema = {\n+        'type': 'object',\n+        'properties': {\n+            'category': {'type': 'string', 'enum': ['movie', 'tvsearch', 'tv', 'search']},\n+            'url': {'type': 'string', 'format': 'url'},\n+            'website': {'type': 'string', 'format': 'url'},\n+            'apikey': {'type': 'string'}\n+        },\n+        'required': ['category'],\n+        'additionalProperties': False\n+    }\n+\n+    def build_config(self, config):\n+        log.debug(type(config))\n+\n+        if config['category'] == 'tv':\n+            config['category'] = 'tvsearch'\n+\n+        if 'url' not in config:\n+            if 'apikey' in config and 'website' in config:\n+                params = {\n+                    't': config['category'],\n+                    'apikey': config['apikey'],\n+                    'extended': 1\n+                }\n+                config['url'] = config['website'] + '/api?' + urlencode(params)\n+\n+        return config\n+\n+    def fill_entries_for_url(self, url, task):\n+        entries = []\n+        log.verbose('Fetching %s' % url)\n+\n+        try:\n+            r = task.requests.get(url)\n+        except task.requests.RequestException as e:\n+            log.error(\"Failed fetching '%s': %s\" % (url, e))\n+\n+        rss = feedparser.parse(r.content)\n+        log.debug(\"Raw RSS: %s\" % rss)\n+\n+        if not len(rss.entries):\n+            log.info('No results returned')\n+\n+        for rss_entry in rss.entries:\n+            new_entry = Entry()\n+\n+            for key in list(rss_entry.keys()):\n+                new_entry[key] = rss_entry[key]\n+            new_entry['url'] = new_entry['link']\n+            if rss_entry.enclosures:\n+                size = int(rss_entry.enclosures[0]['length'])  # B\n+                new_entry['content_size'] = old_div(size, 2 ** 20)  # MB\n+            entries.append(new_entry)\n+        return entries\n+\n+    def search(self, task, entry, config=None):\n+        config = self.build_config(config)\n+        if config['category'] == 'movie':\n+            return self.do_search_movie(entry, task, config)\n+        elif config['category'] == 'tvsearch':\n+            return self.do_search_tvsearch(entry, task, config)\n+        elif config['category'] == 'search':\n+            return self.do_search_search(entry, task, config)\n+        else:\n+            entries = []\n+            log.warning(\"Not done yet...\")","path":"flexget/plugins/sites/jackett_torznab.py","position":102,"original_position":102,"commit_id":"03005a54baa4a7725fa39b7b860fc89ddcf56927","original_commit_id":"03005a54baa4a7725fa39b7b860fc89ddcf56927","user":{"login":"liiight","id":4374581,"avatar_url":"https://avatars.githubusercontent.com/u/4374581?v=3","gravatar_id":"","url":"https://api.github.com/users/liiight","html_url":"https://github.com/liiight","followers_url":"https://api.github.com/users/liiight/followers","following_url":"https://api.github.com/users/liiight/following{/other_user}","gists_url":"https://api.github.com/users/liiight/gists{/gist_id}","starred_url":"https://api.github.com/users/liiight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liiight/subscriptions","organizations_url":"https://api.github.com/users/liiight/orgs","repos_url":"https://api.github.com/users/liiight/repos","events_url":"https://api.github.com/users/liiight/events{/privacy}","received_events_url":"https://api.github.com/users/liiight/received_events","type":"User","site_admin":false},"body":"i dont think this should be here...","created_at":"2016-08-28T14:19:54Z","updated_at":"2016-08-28T14:19:54Z","html_url":"https://github.com/Flexget/Flexget/pull/1379#discussion_r76532778","pull_request_url":"https://api.github.com/repos/Flexget/Flexget/pulls/1379","_links":{"self":{"href":"https://api.github.com/repos/Flexget/Flexget/pulls/comments/76532778"},"html":{"href":"https://github.com/Flexget/Flexget/pull/1379#discussion_r76532778"},"pull_request":{"href":"https://api.github.com/repos/Flexget/Flexget/pulls/1379"}}},"pull_request":{"url":"https://api.github.com/repos/Flexget/Flexget/pulls/1379","id":83016977,"html_url":"https://github.com/Flexget/Flexget/pull/1379","diff_url":"https://github.com/Flexget/Flexget/pull/1379.diff","patch_url":"https://github.com/Flexget/Flexget/pull/1379.patch","issue_url":"https://api.github.com/repos/Flexget/Flexget/issues/1379","number":1379,"state":"open","locked":false,"title":"Jackett torznab","user":{"login":"Davst","id":3330933,"avatar_url":"https://avatars.githubusercontent.com/u/3330933?v=3","gravatar_id":"","url":"https://api.github.com/users/Davst","html_url":"https://github.com/Davst","followers_url":"https://api.github.com/users/Davst/followers","following_url":"https://api.github.com/users/Davst/following{/other_user}","gists_url":"https://api.github.com/users/Davst/gists{/gist_id}","starred_url":"https://api.github.com/users/Davst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Davst/subscriptions","organizations_url":"https://api.github.com/users/Davst/orgs","repos_url":"https://api.github.com/users/Davst/repos","events_url":"https://api.github.com/users/Davst/events{/privacy}","received_events_url":"https://api.github.com/users/Davst/received_events","type":"User","site_admin":false},"body":"An adaption of the existing newsnab plugin (very similar to torznab) to add support for running a local Jackett instance which adds discover & search functionality to a large number of trackers\r\n\r\nhttps://github.com/Jackett/Jackett","created_at":"2016-08-28T14:15:15Z","updated_at":"2016-08-28T14:19:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"53995d1c77c4bee28f1a0bcc695f83c60ad7c174","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Flexget/Flexget/pulls/1379/commits","review_comments_url":"https://api.github.com/repos/Flexget/Flexget/pulls/1379/comments","review_comment_url":"https://api.github.com/repos/Flexget/Flexget/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Flexget/Flexget/issues/1379/comments","statuses_url":"https://api.github.com/repos/Flexget/Flexget/statuses/03005a54baa4a7725fa39b7b860fc89ddcf56927","head":{"label":"Davst:Jackett_torznab","ref":"Jackett_torznab","sha":"03005a54baa4a7725fa39b7b860fc89ddcf56927","user":{"login":"Davst","id":3330933,"avatar_url":"https://avatars.githubusercontent.com/u/3330933?v=3","gravatar_id":"","url":"https://api.github.com/users/Davst","html_url":"https://github.com/Davst","followers_url":"https://api.github.com/users/Davst/followers","following_url":"https://api.github.com/users/Davst/following{/other_user}","gists_url":"https://api.github.com/users/Davst/gists{/gist_id}","starred_url":"https://api.github.com/users/Davst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Davst/subscriptions","organizations_url":"https://api.github.com/users/Davst/orgs","repos_url":"https://api.github.com/users/Davst/repos","events_url":"https://api.github.com/users/Davst/events{/privacy}","received_events_url":"https://api.github.com/users/Davst/received_events","type":"User","site_admin":false},"repo":{"id":66755585,"name":"Flexget","full_name":"Davst/Flexget","owner":{"login":"Davst","id":3330933,"avatar_url":"https://avatars.githubusercontent.com/u/3330933?v=3","gravatar_id":"","url":"https://api.github.com/users/Davst","html_url":"https://github.com/Davst","followers_url":"https://api.github.com/users/Davst/followers","following_url":"https://api.github.com/users/Davst/following{/other_user}","gists_url":"https://api.github.com/users/Davst/gists{/gist_id}","starred_url":"https://api.github.com/users/Davst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Davst/subscriptions","organizations_url":"https://api.github.com/users/Davst/orgs","repos_url":"https://api.github.com/users/Davst/repos","events_url":"https://api.github.com/users/Davst/events{/privacy}","received_events_url":"https://api.github.com/users/Davst/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Davst/Flexget","description":"The official FlexGet repository","fork":true,"url":"https://api.github.com/repos/Davst/Flexget","forks_url":"https://api.github.com/repos/Davst/Flexget/forks","keys_url":"https://api.github.com/repos/Davst/Flexget/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Davst/Flexget/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Davst/Flexget/teams","hooks_url":"https://api.github.com/repos/Davst/Flexget/hooks","issue_events_url":"https://api.github.com/repos/Davst/Flexget/issues/events{/number}","events_url":"https://api.github.com/repos/Davst/Flexget/events","assignees_url":"https://api.github.com/repos/Davst/Flexget/assignees{/user}","branches_url":"https://api.github.com/repos/Davst/Flexget/branches{/branch}","tags_url":"https://api.github.com/repos/Davst/Flexget/tags","blobs_url":"https://api.github.com/repos/Davst/Flexget/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Davst/Flexget/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Davst/Flexget/git/refs{/sha}","trees_url":"https://api.github.com/repos/Davst/Flexget/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Davst/Flexget/statuses/{sha}","languages_url":"https://api.github.com/repos/Davst/Flexget/languages","stargazers_url":"https://api.github.com/repos/Davst/Flexget/stargazers","contributors_url":"https://api.github.com/repos/Davst/Flexget/contributors","subscribers_url":"https://api.github.com/repos/Davst/Flexget/subscribers","subscription_url":"https://api.github.com/repos/Davst/Flexget/subscription","commits_url":"https://api.github.com/repos/Davst/Flexget/commits{/sha}","git_commits_url":"https://api.github.com/repos/Davst/Flexget/git/commits{/sha}","comments_url":"https://api.github.com/repos/Davst/Flexget/comments{/number}","issue_comment_url":"https://api.github.com/repos/Davst/Flexget/issues/comments{/number}","contents_url":"https://api.github.com/repos/Davst/Flexget/contents/{+path}","compare_url":"https://api.github.com/repos/Davst/Flexget/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Davst/Flexget/merges","archive_url":"https://api.github.com/repos/Davst/Flexget/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Davst/Flexget/downloads","issues_url":"https://api.github.com/repos/Davst/Flexget/issues{/number}","pulls_url":"https://api.github.com/repos/Davst/Flexget/pulls{/number}","milestones_url":"https://api.github.com/repos/Davst/Flexget/milestones{/number}","notifications_url":"https://api.github.com/repos/Davst/Flexget/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Davst/Flexget/labels{/name}","releases_url":"https://api.github.com/repos/Davst/Flexget/releases{/id}","deployments_url":"https://api.github.com/repos/Davst/Flexget/deployments","created_at":"2016-08-28T07:30:04Z","updated_at":"2016-08-28T07:30:15Z","pushed_at":"2016-08-28T14:11:19Z","git_url":"git://github.com/Davst/Flexget.git","ssh_url":"git@github.com:Davst/Flexget.git","clone_url":"https://github.com/Davst/Flexget.git","svn_url":"https://github.com/Davst/Flexget","homepage":"http://www.flexget.com","size":51389,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"Flexget:develop","ref":"develop","sha":"debe263e0c2578b0f91ba7f81a017dcf20db561b","user":{"login":"Flexget","id":682553,"avatar_url":"https://avatars.githubusercontent.com/u/682553?v=3","gravatar_id":"","url":"https://api.github.com/users/Flexget","html_url":"https://github.com/Flexget","followers_url":"https://api.github.com/users/Flexget/followers","following_url":"https://api.github.com/users/Flexget/following{/other_user}","gists_url":"https://api.github.com/users/Flexget/gists{/gist_id}","starred_url":"https://api.github.com/users/Flexget/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Flexget/subscriptions","organizations_url":"https://api.github.com/users/Flexget/orgs","repos_url":"https://api.github.com/users/Flexget/repos","events_url":"https://api.github.com/users/Flexget/events{/privacy}","received_events_url":"https://api.github.com/users/Flexget/received_events","type":"Organization","site_admin":false},"repo":{"id":1512901,"name":"Flexget","full_name":"Flexget/Flexget","owner":{"login":"Flexget","id":682553,"avatar_url":"https://avatars.githubusercontent.com/u/682553?v=3","gravatar_id":"","url":"https://api.github.com/users/Flexget","html_url":"https://github.com/Flexget","followers_url":"https://api.github.com/users/Flexget/followers","following_url":"https://api.github.com/users/Flexget/following{/other_user}","gists_url":"https://api.github.com/users/Flexget/gists{/gist_id}","starred_url":"https://api.github.com/users/Flexget/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Flexget/subscriptions","organizations_url":"https://api.github.com/users/Flexget/orgs","repos_url":"https://api.github.com/users/Flexget/repos","events_url":"https://api.github.com/users/Flexget/events{/privacy}","received_events_url":"https://api.github.com/users/Flexget/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Flexget/Flexget","description":"The official FlexGet repository","fork":false,"url":"https://api.github.com/repos/Flexget/Flexget","forks_url":"https://api.github.com/repos/Flexget/Flexget/forks","keys_url":"https://api.github.com/repos/Flexget/Flexget/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Flexget/Flexget/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Flexget/Flexget/teams","hooks_url":"https://api.github.com/repos/Flexget/Flexget/hooks","issue_events_url":"https://api.github.com/repos/Flexget/Flexget/issues/events{/number}","events_url":"https://api.github.com/repos/Flexget/Flexget/events","assignees_url":"https://api.github.com/repos/Flexget/Flexget/assignees{/user}","branches_url":"https://api.github.com/repos/Flexget/Flexget/branches{/branch}","tags_url":"https://api.github.com/repos/Flexget/Flexget/tags","blobs_url":"https://api.github.com/repos/Flexget/Flexget/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Flexget/Flexget/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Flexget/Flexget/git/refs{/sha}","trees_url":"https://api.github.com/repos/Flexget/Flexget/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Flexget/Flexget/statuses/{sha}","languages_url":"https://api.github.com/repos/Flexget/Flexget/languages","stargazers_url":"https://api.github.com/repos/Flexget/Flexget/stargazers","contributors_url":"https://api.github.com/repos/Flexget/Flexget/contributors","subscribers_url":"https://api.github.com/repos/Flexget/Flexget/subscribers","subscription_url":"https://api.github.com/repos/Flexget/Flexget/subscription","commits_url":"https://api.github.com/repos/Flexget/Flexget/commits{/sha}","git_commits_url":"https://api.github.com/repos/Flexget/Flexget/git/commits{/sha}","comments_url":"https://api.github.com/repos/Flexget/Flexget/comments{/number}","issue_comment_url":"https://api.github.com/repos/Flexget/Flexget/issues/comments{/number}","contents_url":"https://api.github.com/repos/Flexget/Flexget/contents/{+path}","compare_url":"https://api.github.com/repos/Flexget/Flexget/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Flexget/Flexget/merges","archive_url":"https://api.github.com/repos/Flexget/Flexget/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Flexget/Flexget/downloads","issues_url":"https://api.github.com/repos/Flexget/Flexget/issues{/number}","pulls_url":"https://api.github.com/repos/Flexget/Flexget/pulls{/number}","milestones_url":"https://api.github.com/repos/Flexget/Flexget/milestones{/number}","notifications_url":"https://api.github.com/repos/Flexget/Flexget/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Flexget/Flexget/labels{/name}","releases_url":"https://api.github.com/repos/Flexget/Flexget/releases{/id}","deployments_url":"https://api.github.com/repos/Flexget/Flexget/deployments","created_at":"2011-03-22T19:33:44Z","updated_at":"2016-08-28T06:44:15Z","pushed_at":"2016-08-28T14:15:15Z","git_url":"git://github.com/Flexget/Flexget.git","ssh_url":"git@github.com:Flexget/Flexget.git","clone_url":"https://github.com/Flexget/Flexget.git","svn_url":"https://github.com/Flexget/Flexget","homepage":"http://www.flexget.com","size":51412,"stargazers_count":533,"watchers_count":533,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":307,"mirror_url":null,"open_issues_count":82,"forks":307,"open_issues":82,"watchers":533,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/Flexget/Flexget/pulls/1379"},"html":{"href":"https://github.com/Flexget/Flexget/pull/1379"},"issue":{"href":"https://api.github.com/repos/Flexget/Flexget/issues/1379"},"comments":{"href":"https://api.github.com/repos/Flexget/Flexget/issues/1379/comments"},"review_comments":{"href":"https://api.github.com/repos/Flexget/Flexget/pulls/1379/comments"},"review_comment":{"href":"https://api.github.com/repos/Flexget/Flexget/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Flexget/Flexget/pulls/1379/commits"},"statuses":{"href":"https://api.github.com/repos/Flexget/Flexget/statuses/03005a54baa4a7725fa39b7b860fc89ddcf56927"}}}}
{"actor":{"display_login":"liiight"}}