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