Skip to content

Commit

Permalink
#275 Fix Jackett's url params
Browse files Browse the repository at this point in the history
%-encode Torznab querystrings since Jackett doesn't.
  • Loading branch information
nosmokingbandit committed Oct 5, 2018
1 parent 5c05f3e commit 0217e75
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion core/providers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from xmljson import yahoo
import logging
import re
import urllib.parse

import core
from core.helpers import Url
Expand Down Expand Up @@ -135,11 +136,25 @@ def parse_newznab_xml(self, feed, imdbid=None):
for i in item['{ns}attr']:
item['attr'][i['name']] = i['value']

if(self.feed_type == 'torrent'):
# Jackett doesn't properly encode query string params so we do it here.
rt, qs = item.get('link', '?').split('?')
if rt == qs == '':
guid = None
else:
rt = rt + '?'
qsprs = urllib.parse.parse_qs(qs)
for k in qsprs:
rt += '{}={}&'.format(k, urllib.parse.quote(qsprs[k][0]))
guid = rt[:-1]
else:
guid = item.get('link')

result = {
"download_client": None,
"downloadid": None,
"freeleech": 1 if item['attr'].get('downloadvolumefactor', 1) == 0 else 0,
"guid": item.get('link'),
"guid": guid,
"indexer": indexer,
"info_link": item.get('comments', '').split('#')[0],
"imdbid": imdbid if imdbid is not None else 'tt{}'.format(item['attr'].get('imdb')),
Expand Down

0 comments on commit 0217e75

Please sign in to comment.