Commit 7fcb140b authored by echel0n's avatar echel0n
Browse files

replaced bencode3 requirement with bencode.py

parent 650ccb0a
...@@ -9,7 +9,7 @@ asn1crypto==1.4.0 ...@@ -9,7 +9,7 @@ asn1crypto==1.4.0
attrs==19.3.0 attrs==19.3.0
babelfish==0.6.0 babelfish==0.6.0
beautifulsoup4==4.10.0 beautifulsoup4==4.10.0
bencode3==0.1.0 bencode.py==4.0.0
bleach==3.3.0 bleach==3.3.0
CacheControl==0.12.6 CacheControl==0.12.6
certifi==2021.5.30 certifi==2021.5.30
......
...@@ -19,11 +19,10 @@ ...@@ -19,11 +19,10 @@
import re import re
import time import time
import bencodepy
from base64 import b16encode, b32decode from base64 import b16encode, b32decode
from hashlib import sha1 from hashlib import sha1
from bencode3 import bdecode, BencodeError, bencode
import sickrage import sickrage
from sickrage.core.websession import WebSession from sickrage.core.websession import WebSession
from sickrage.search_providers import SearchProviderType from sickrage.search_providers import SearchProviderType
...@@ -186,8 +185,8 @@ class TorrentClient(GenericClient): ...@@ -186,8 +185,8 @@ class TorrentClient(GenericClient):
raise Exception('Torrent without content') raise Exception('Torrent without content')
try: try:
torrent_bdecode = bdecode(result.content) torrent_bdecode = bencodepy.decode(result.content)
except BencodeError: except bencodepy.exceptions.BencodeDecodeError:
sickrage.app.log.warning('Unable to bdecode torrent') sickrage.app.log.warning('Unable to bdecode torrent')
sickrage.app.log.debug('Torrent bencoded data: %r' % result.content) sickrage.app.log.debug('Torrent bencoded data: %r' % result.content)
raise raise
...@@ -198,7 +197,7 @@ class TorrentClient(GenericClient): ...@@ -198,7 +197,7 @@ class TorrentClient(GenericClient):
sickrage.app.log.warning('Unable to find info field in torrent') sickrage.app.log.warning('Unable to find info field in torrent')
raise raise
result.hash = sha1(bencode(info)).hexdigest() result.hash = sha1(bencodepy.encode(info)).hexdigest()
return result return result
......
...@@ -25,7 +25,6 @@ import enum ...@@ -25,7 +25,6 @@ import enum
import importlib import importlib
import inspect import inspect
import itertools import itertools
import json
import os import os
import pkgutil import pkgutil
import random import random
...@@ -36,7 +35,7 @@ from time import sleep ...@@ -36,7 +35,7 @@ from time import sleep
from urllib.parse import urljoin from urllib.parse import urljoin
from xml.sax import SAXParseException from xml.sax import SAXParseException
from bencode3 import bdecode, bencode import bencodepy
from feedparser import FeedParserDict from feedparser import FeedParserDict
from requests.utils import add_dict_to_cookiejar, dict_from_cookiejar from requests.utils import add_dict_to_cookiejar, dict_from_cookiejar
from tornado.ioloop import IOLoop from tornado.ioloop import IOLoop
...@@ -775,7 +774,7 @@ class TorrentProvider(SearchProvider): ...@@ -775,7 +774,7 @@ class TorrentProvider(SearchProvider):
def verify_torrent(content): def verify_torrent(content):
try: try:
if bdecode(content).get('info'): if bencodepy.decode(content).get('info'):
return content return content
except Exception: except Exception:
pass pass
...@@ -883,14 +882,14 @@ class TorrentProvider(SearchProvider): ...@@ -883,14 +882,14 @@ class TorrentProvider(SearchProvider):
# adds public torrent trackers to content # adds public torrent trackers to content
if result.content: if result.content:
decoded_data = bdecode(result.content) decoded_data = bencodepy.decode(result.content)
if not decoded_data.get('announce-list'): if not decoded_data.get('announce-list'):
decoded_data['announce-list'] = [] decoded_data['announce-list'] = []
for tracker in trackers_list: for tracker in trackers_list:
if tracker not in decoded_data['announce-list']: if tracker not in decoded_data['announce-list']:
decoded_data['announce-list'].append([str(tracker)]) decoded_data['announce-list'].append([str(tracker)])
result.content = bencode(decoded_data) result.content = bencodepy.encode(decoded_data)
return result return result
...@@ -1059,7 +1058,7 @@ class TorrentRssProvider(TorrentProvider): ...@@ -1059,7 +1058,7 @@ class TorrentRssProvider(TorrentProvider):
else: else:
try: try:
torrent_file = self.session.get(url).content torrent_file = self.session.get(url).content
bdecode(torrent_file) bencodepy.decode(torrent_file)
except Exception as e: except Exception as e:
if data: if data:
self.dumpHTML(torrent_file) self.dumpHTML(torrent_file)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment