Skip to content
Permalink
Browse files
Blacken and isort all files with latest versions/settings
  • Loading branch information
gazpachoking committed Sep 8, 2020
1 parent de3cde1 commit b62360553029af69608812ce497710c21f43ae4e
Showing with 135 additions and 89 deletions.
  1. +4 −1 dev_tools.py
  2. +1 −1 flexget/components/archive/cli.py
  3. +1 −1 flexget/components/ftp/ftp_list.py
  4. +6 −2 flexget/components/imdb/imdb_lookup.py
  5. +4 −2 flexget/components/imdb/utils.py
  6. +1 −1 flexget/components/irc/irc.py
  7. +7 −7 flexget/components/notify/notifiers/toast.py
  8. +1 −1 flexget/components/seen/cli.py
  9. +4 −6 flexget/components/sites/sites/filelist.py
  10. +17 −5 flexget/components/sites/sites/filelist_api.py
  11. +10 −5 flexget/components/sites/sites/iptorrents.py
  12. +12 −3 flexget/components/sites/sites/newznab.py
  13. +3 −4 flexget/components/sites/sites/site_rutracker.py
  14. +5 −1 flexget/components/thetvdb/api_tvdb.py
  15. +3 −1 flexget/components/trakt/trakt_calendar.py
  16. +4 −3 flexget/plugins/cli/perf_tests.py
  17. +3 −6 flexget/plugins/clients/pyload.py
  18. +2 −3 flexget/plugins/clients/transmission.py
  19. +3 −3 flexget/plugins/filter/crossmatch.py
  20. +1 −1 flexget/plugins/input/filmweb_watchlist.py
  21. +1 −1 flexget/plugins/input/generate.py
  22. +6 −7 flexget/plugins/input/json.py
  23. +3 −3 flexget/plugins/input/torznab.py
  24. +2 −2 flexget/plugins/metainfo/subtitles_check.py
  25. +3 −3 flexget/plugins/output/subtitles_subliminal.py
  26. +8 −4 flexget/task.py
  27. +1 −0 flexget/tests/api_tests/test_series_api.py
  28. +13 −5 flexget/tests/test_imdb_parser.py
  29. +2 −2 flexget/tests/test_serialization.py
  30. +1 −2 flexget/tests/test_urlrewriting.py
  31. +1 −1 flexget/utils/json.py
  32. +1 −1 flexget/utils/serialization.py
  33. +1 −1 flexget/utils/sqlalchemy_utils.py
@@ -86,7 +86,10 @@ def download_extract(url, dest_path):
shutil.rmtree(app_path)
# Just stashed the old webui zip on a random github release for easy hosting.
# It doesn't get updated anymore, we should probably stop bundling it with releases soon.
download_extract('https://github.com/Flexget/Flexget/releases/download/v3.0.6/webui_v1.zip', os.path.join(ui_path, 'v1'))
download_extract(
'https://github.com/Flexget/Flexget/releases/download/v3.0.6/webui_v1.zip',
os.path.join(ui_path, 'v1'),
)
except OSError as e:
click.echo('Unable to download and extract WebUI v1 due to %e' % str(e))
raise click.Abort()
@@ -41,7 +41,7 @@ def consolidate():
logger.verbose('Found {} items to migrate, this can be aborted with CTRL-C safely.', count)

# consolidate old data
from progressbar import ProgressBar, Percentage, Bar, ETA
from progressbar import ETA, Bar, Percentage, ProgressBar

widgets = ['Process - ', ETA(), ' ', Percentage(), ' ', Bar(left='[', right=']')]
bar = ProgressBar(widgets=widgets, maxval=count).start()
@@ -9,9 +9,9 @@
from flexget.plugin import DependencyError, PluginError

try:
from ftputil.error import FTPOSError
import ftputil
import ftputil.session
from ftputil.error import FTPOSError

imported = True
except ImportError:
@@ -45,7 +45,9 @@ class ImdbLookup:
(writer.imdb_id, writer.name) for writer in movie.writers
),
'imdb_mpaa_rating': 'mpaa_rating',
'imdb_plot_keywords': lambda movie: [plot_keyword.name for plot_keyword in movie.plot_keywords],
'imdb_plot_keywords': lambda movie: [
plot_keyword.name for plot_keyword in movie.plot_keywords
],
# Generic fields filled by all movie lookup plugins:
'movie_name': 'title',
'movie_year': 'year',
@@ -301,7 +303,9 @@ def _parse_new_movie(self, imdb_url, session):
writer = db.Writer(imdb_id, name)
movie.writers.append(writer) # pylint:disable=E1101
for name in parser.plot_keywords:
plot_keyword = session.query(db.PlotKeyword).filter(db.PlotKeyword.name == name).first()
plot_keyword = (
session.query(db.PlotKeyword).filter(db.PlotKeyword.name == name).first()
)
if not plot_keyword:
plot_keyword = db.PlotKeyword(name)
movie.plot_keywords.append(plot_keyword) # pylint:disable=E1101
@@ -270,7 +270,7 @@ def __init__(self):
self.imdb_id = None
self.photo = None
self.mpaa_rating = ''
self.plot_keywords=[]
self.plot_keywords = []

def __str__(self):
return '<ImdbParser(name=%s,imdb_id=%s)>' % (self.name, self.imdb_id)
@@ -399,7 +399,9 @@ def parse(self, imdb_id, soup=None):
keyword_elem = storyline.find('h4').parent
if keyword_elem:
# The last "a" tag is a link to the full list
self.plot_keywords = [keyword_elem.text.strip() for keyword_elem in keyword_elem.find_all("a")[:-1]]
self.plot_keywords = [
keyword_elem.text.strip() for keyword_elem in keyword_elem.find_all("a")[:-1]
]

genres = data.get('genre', [])
if not isinstance(genres, list):
@@ -17,8 +17,8 @@
from flexget.utils.tools import get_config_hash

try:
from irc_bot.simple_irc_bot import SimpleIRCBot, partial
from irc_bot import utils as irc_bot
from irc_bot.simple_irc_bot import SimpleIRCBot, partial
except ImportError as e:
irc_bot = None
SimpleIRCBot = object
@@ -106,31 +106,31 @@ def windows_notify(self, title, message, config):
from win32api import GetModuleHandle, PostQuitMessage
from win32con import (
CW_USEDEFAULT,
IMAGE_ICON,
IDI_APPLICATION,
IMAGE_ICON,
LR_DEFAULTSIZE,
LR_LOADFROMFILE,
WM_DESTROY,
WM_USER,
WS_OVERLAPPED,
WS_SYSMENU,
WM_USER,
)
from win32gui import (
CreateWindow,
DestroyWindow,
LoadIcon,
LoadImage,
NIF_ICON,
NIF_INFO,
NIF_MESSAGE,
NIF_TIP,
NIM_ADD,
NIM_DELETE,
NIM_MODIFY,
WNDCLASS,
CreateWindow,
DestroyWindow,
LoadIcon,
LoadImage,
RegisterClass,
Shell_NotifyIcon,
UpdateWindow,
WNDCLASS,
)
except ImportError:
raise DependencyError(
@@ -7,7 +7,7 @@

try:
# NOTE: Importing other plugins is discouraged!
from flexget.components.imdb.utils import is_imdb_url, extract_id
from flexget.components.imdb.utils import extract_id, is_imdb_url
except ImportError:
raise plugin.DependencyError(issued_by=__name__, missing='imdb')

@@ -148,16 +148,14 @@ def get_login_cookie(self, username, password, force=False):
# get validator token
response = requests.get(BASE_URL + 'login.php')
soup = get_soup(response.content)

login_validator = soup.find("input", {"name": "validator"})

if not login_validator:
raise plugin.PluginError(
'FileList.ro could not get login validator'
)
raise plugin.PluginError('FileList.ro could not get login validator')
logger.debug('Login Validator: {}'.format(login_validator.get('value')))
logger.debug('Attempting to retrieve FileList.ro cookie')

response = requests.post(
url,
data={
@@ -1,5 +1,7 @@
from http import HTTPStatus

from loguru import logger

from flexget import plugin
from flexget.config_schema import one_or_more
from flexget.entry import Entry
@@ -49,7 +51,7 @@ class SearchFileList:
}

valid_extras = ['internal', 'moderated', 'freeleech', 'doubleup']

schema = {
'type': 'object',
'properties': {
@@ -76,7 +78,9 @@ def get(self, url, params):
http_status = HTTPStatus(response.status_code)
error_message = response.json().get('error', http_status.description)

raise plugin.PluginError(f'FileList request failed; err code: {http_status}; err msg: `{error_message}`')
raise plugin.PluginError(
f'FileList request failed; err code: {http_status}; err msg: `{error_message}`'
)

return response

@@ -88,7 +92,11 @@ def search(self, task, entry, config):
entries = []

# mandatory params
params = {'username': config['username'], 'passkey': config['passkey'], 'action': 'search-torrents'}
params = {
'username': config['username'],
'passkey': config['passkey'],
'action': 'search-torrents',
}

# category
if config.get('category'):
@@ -127,7 +135,9 @@ def search(self, task, entry, config):
if not results:
logger.verbose('No torrent found on Filelist for `{}`', search_title)
else:
logger.verbose('{} torrent(s) were found on Filelist for `{}`', len(results), search_title)
logger.verbose(
'{} torrent(s) were found on Filelist for `{}`', len(results), search_title
)

for result in results:
entry = Entry()
@@ -143,7 +153,9 @@ def search(self, task, entry, config):
entry['torrent_internal'] = bool(result['internal'])
entry['torrent_moderated'] = bool(result['moderated'])
entry['torrent_freeleech'] = bool(result['freeleech'])
entry['torrent_genres'] = [genres.strip() for genres in result['small_description'].split(',')]
entry['torrent_genres'] = [
genres.strip() for genres in result['small_description'].split(',')
]

entries.append(entry)

@@ -57,6 +57,7 @@
SEARCH_URL = 'https://iptorrents.com/t?'
FREE_SEARCH_URL = 'https://iptorrents.com/t?free=on'


class UrlRewriteIPTorrents:
"""
IpTorrents urlrewriter and search plugin.
@@ -128,24 +129,28 @@ def search(self, task, entry, config=None):

# If there are any text categories, turn them into their id number
categories = [c if isinstance(c, int) else CATEGORIES[c] for c in categories]
category_params = {str(c):'' for c in categories if str(c)}
category_params = {str(c): '' for c in categories if str(c)}

entries = set()

for search_string in entry.get('search_strings', [entry['title']]):
search_params = {key:value for (key,value) in category_params.items()}
search_params = {key: value for (key, value) in category_params.items()}

query = normalize_unicode(search_string)
search_params.update({'q':query, 'qf':''})
search_params.update({'q': query, 'qf': ''})

logger.debug('searching with params: {}', search_params)
if config.get('free'):
req = requests.get(
FREE_SEARCH_URL, params=search_params, cookies={'uid': str(config['uid']), 'pass': config['password']}
FREE_SEARCH_URL,
params=search_params,
cookies={'uid': str(config['uid']), 'pass': config['password']},
)
else:
req = requests.get(
SEARCH_URL, params=search_params, cookies={'uid': str(config['uid']), 'pass': config['password']}
SEARCH_URL,
params=search_params,
cookies={'uid': str(config['uid']), 'pass': config['password']},
)
logger.debug('full search URL: {}', req.url)

@@ -30,7 +30,10 @@ class Newznab:
schema = {
'type': 'object',
'properties': {
'category': {'type': 'string', 'enum': ['movie', 'tvsearch', 'tv', 'music', 'book', 'all']},
'category': {
'type': 'string',
'enum': ['movie', 'tvsearch', 'tv', 'music', 'book', 'all'],
},
'url': {'type': 'string', 'format': 'url'},
'website': {'type': 'string', 'format': 'url'},
'apikey': {'type': 'string'},
@@ -49,7 +52,11 @@ def build_config(self, config):

if 'url' not in config:
if 'apikey' in config and 'website' in config:
config['params'] = {'t': config['category'], 'apikey': config['apikey'], 'extended': 1}
config['params'] = {
't': config['category'],
'apikey': config['apikey'],
'extended': 1,
}
config['url'] = f"{config['website']}/api"

return config
@@ -92,7 +99,9 @@ def search(self, task, entry, config=None):
return self.do_search_all(entry, task, config)
else:
entries = []
logger.warning("Work in progress. Searching for the specified category is not supported yet...")
logger.warning(
"Work in progress. Searching for the specified category is not supported yet..."
)
return entries

def do_search_tvsearch(self, arg_entry, task, config=None):
@@ -1,15 +1,14 @@
# -*- coding: utf-8 -*-

from urllib.parse import parse_qs, urlencode, urlparse

from loguru import logger
from requests.exceptions import RequestException

from flexget import plugin
from flexget.components.sites.urlrewriting import UrlRewritingError
from flexget.event import event

from urllib.parse import urlparse, parse_qs, urlencode


logger = logger.bind(name='rutracker')


@@ -49,7 +48,7 @@ def url_rewrite(self, task, entry):
magnet = {
'xt': f"urn:btih:{topic['info_hash']}",
'tr': [f'http://bt{i}.t-ru.org/ann?magnet' for i in ['', '2', '3', '4']],
'dn': topic['topic_title']
'dn': topic['topic_title'],
}
magnet_qs = urlencode(magnet, doseq=True, safe=':')
magnet_uri = f"magnet:?{magnet_qs}"
@@ -481,7 +481,11 @@ def find_series_id(name, language=None):
try:
s['firstAired'] = datetime.strptime(s['firstAired'], "%Y-%m-%d")
except ValueError:
logger.warning('Invalid firstAired date "{}" when parsing series {} ', s['firstAired'], s['seriesName'])
logger.warning(
'Invalid firstAired date "{}" when parsing series {} ',
s['firstAired'],
s['seriesName'],
)
s['firstAired'] = datetime(1970, 1, 1)
else:
s['firstAired'] = datetime(1970, 1, 1)
@@ -112,7 +112,9 @@ def on_task_input(self, task, config):

try:
results = (
db.get_session(config.get('account')).get(url, params={'extended': 'full'}).json()
db.get_session(config.get('account'))
.get(url, params={'extended': 'full'})
.json()
)
logger.debug('Found {} calendar entries', len(results))
except RequestException as e:
@@ -25,12 +25,13 @@ def cli_perf_test(manager, options):
def imdb_query(session):
import time

from progressbar import ETA, Bar, Percentage, ProgressBar
from sqlalchemy.orm import joinedload_all
from sqlalchemy.sql.expression import select

# NOTE: importing other plugins directly is discouraged
from flexget.components.imdb.db import Movie
from flexget.plugins.cli.performance import log_query_count
from sqlalchemy.sql.expression import select
from progressbar import ProgressBar, Percentage, Bar, ETA
from sqlalchemy.orm import joinedload_all

imdb_urls = []

@@ -8,6 +8,7 @@
from flexget.event import event
from flexget.utils import json
from flexget.utils.template import RenderError

logger = logger.bind(name='pyload')


@@ -175,11 +176,7 @@ def add_entries(self, task, config):
content = json.dumps(content)

if is_pyload_ng:
url = (
entry['url']
if config.get('parse_url', self.DEFAULT_PARSE_URL)
else ''
)
url = entry['url'] if config.get('parse_url', self.DEFAULT_PARSE_URL) else ''
else:
url = (
json.dumps(entry['url'])
@@ -251,7 +248,7 @@ def add_entries(self, task, config):
'name': json.dumps(name.encode('ascii', 'ignore').decode()),
'links': json.dumps(urls),
'dest': json.dumps(dest),
'session': session
'session': session,
}

pid = api.post(add_package_command, data=data).text

0 comments on commit b623605

Please sign in to comment.