qBittorrent Enhanced Edition v4.5.3.zip
立即下载
资源介绍:
qBittorrent Enhanced Edition v4.5.3.zip
#VERSION: 0.20
#AUTHORS: Bugsbringer (dastins193@gmail.com)
EMAIL = "YOUR_EMAIL"
PASSWORD = "YOUR_PASSWORD"
proxy = {
'enable': False,
'proxy_urls': {
'http': 'ip:port',
'https': 'ip:port'
},
'auth': False,
'username': '',
'password': ''
}
ENABLE_PEERS_INFO = True
import concurrent.futures
import hashlib
import json
import logging
import os
import re
from collections import OrderedDict
from datetime import datetime
from html.parser import HTMLParser
from http.cookiejar import CookieJar
from io import BytesIO
from random import randint
from urllib import parse, request
from novaprinter import prettyPrinter
STORAGE = os.path.abspath(os.path.dirname(__file__))
# logging
LOG_FORMAT = '[%(asctime)s] %(levelname)s:%(name)s:%(funcName)s - %(message)s'
LOG_DT_FORMAT = '%d-%b-%y %H:%M:%S'
if __name__ == '__main__':
logging.basicConfig(
level='DEBUG',
format=LOG_FORMAT,
datefmt=LOG_DT_FORMAT
)
else:
logging.basicConfig(
level='ERROR',
filename=os.path.join(STORAGE, 'lostfilm.log'),
format=LOG_FORMAT,
datefmt=LOG_DT_FORMAT
)
logger = logging.getLogger('lostfilm')
logger.setLevel(logging.WARNING)
#proxy
if proxy['enable'] and proxy['auth']:
for scheme, proxy_url in proxy['proxy_urls'].items():
proxy[scheme] = '{}:{}@{}'.format(proxy['username'], proxy['password'], proxy_url)
class lostfilm:
url = 'https://www.lostfilm.tv'
name = 'LostFilm'
supported_categories = {'all': '0'}
search_url_pattern = 'https://www.lostfilm.tv/search/?q={what}'
serial_url_pattern = 'https://www.lostfilm.tv{href}/seasons'
download_url_pattern = 'https://www.lostfilm.tv/v_search.php?a={code}'
season_url_pattern = 'https://www.lostfilm.tv{href}/season_{season}'
episode_url_pattern = 'https://www.lostfilm.tv{href}/season_{season}/episode_{episode}/'
additional_url_pattern = 'https://www.lostfilm.tv{href}/additional/episode_{episode}/'
new_url_pattern = "https://www.lostfilm.tv/new/page_{page}/type_{type}"
additional_season = 999
all_episodes = 999
peer_id = '-PC0001-' + ''.join([str(randint(0, 9)) for _ in range(12)])
datetime_format = '%d.%m.%Y'
units_dict = {"ТБ": "TB", "ГБ": "GB", "МБ": "MB", "КБ": "KB", "Б": "B"}
def __init__(self):
self.session = Session()
def search(self, what, cat='all'):
self.torrents_count = 0
logger.info(what)
if not self.session.is_actual:
self.pretty_printer({
'link': 'Error',
'name': self.session.error,
'size': "0",
'seeds': -1,
'leech': -1,
'engine_url': self.url,
'desc_link': self.url
})
return False
self.prevs = {}
self.old_seasons = {}
if parse.unquote(what).startswith('@'):
params = parse.unquote(what)[1:].split(':')
if params:
if params[0] == 'fav':
self.get_fav()
elif params[0] == 'new':
if len(params) == 1:
self.get_new()
elif len(params) == 2 and params[1] == 'fav':
self.get_new(fav=True)
else:
try:
url = self.search_url_pattern.format(what=request.quote(what))
search_result = self.session.request(url)
except Exception as exp:
logger.error(exp)
else:
serials_tags = Parser(search_result).find_all('div', {'class': 'row-search'})
if serials_tags:
with concurrent.futures.ThreadPoolExecutor() as executor:
for serial_href in (serial.a['href'] for serial in serials_tags):
logger.debug(serial_href)
executor.submit(self.get_episodes, serial_href)
logger.info('%s torrents', self.torrents_count)
def get_new(self, fav=False, days=7):
type = 99 if fav else 0
today = datetime.now().date()
self.dates = {}
with concurrent.futures.ThreadPoolExecutor() as executor:
page_number = 1
while True:
url = self.new_url_pattern.format(page=page_number, type=type)
page = self.session.request(url)
rows = Parser(page).find_all('div', {'class': 'row'})
if not rows:
break
for row in rows:
release_date_str = row.find_all('div', {'class': 'alpha'})[1].text
release_date_str = re.search(r'\d{2}.\d{2}.\d{4}', release_date_str)[0]
release_date = datetime.strptime(release_date_str, self.datetime_format).date()
date_delta = today - release_date
if date_delta.days > days:
return
href = '/'.join(row.a['href'].split('/')[:3])
haveseen_btn = row.find('div', {'onclick': 'markEpisodeAsWatched(this);'})
episode_code = haveseen_btn['data-episode'].rjust(9, '0')
self.dates[episode_code] = release_date_str
executor.submit(self.get_torrents, href, episode_code, True)
page_number += 1
def get_fav(self):
page = self.session.request("https://www.lostfilm.tv/my/type_1")
with concurrent.futures.ThreadPoolExecutor() as executor:
for serial in Parser(page).find_all('div', {'class': 'serial-box'}):
href = serial.find('a', {'class': 'body'})['href']
executor.submit(self.get_episodes, href)
def get_episodes(self, serial_href):
self.prevs[serial_href] = []
self.old_seasons[serial_href] = 0
serial_page = self.session.request(self.serial_url_pattern.format(href=serial_href))
with concurrent.futures.ThreadPoolExecutor() as executor:
for button in Parser(serial_page).find_all('div', {'class': 'external-btn'}):
item_button = button.attrs.get('onclick')
if item_button:
episode_code = re.search(r'\d{7,9}', item_button)[0].rjust(9, '0')
logger.debug('episode_code = %s', episode_code)
executor.submit(self.get_torrents, serial_href, episode_code)
def get_torrents(self, href, code, new_episodes=False):
season, episode = int(code[3:6]), int(code[6:])
desc_link = self.get_description_url(href, code)
date = ' [' + self.dates.pop(code, '') + ']' if new_episodes else ''
if not new_episodes:
rules = [
season > self.old_seasons[href],
episode == self.all_episodes,
season == self.additional_season
]
if not any(rules):
return
redir_page = self.session.request(self.download_url_pattern.format(code=code))
torrent_page_url = re.search(r'(?<=location.replace\(").+(?="\);)', redir_page)
if not torrent_page_url:
return
torrent_page = self.session.request(torrent_page_url[0])
logger.debug('desc_link = %s', desc_link)
with concurrent.futures.ThreadPoolExecutor() as executor:
for torrent_tag in Parser(torrent_page).find_all('div', {'class': 'inner-box--item'}):
main = torrent_tag.find('div', {'class': 'inner-box--link main'}).a
link, name