Skip to content

Commit

Permalink
Merge branch 'develop' into feature/webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkykh committed Jul 28, 2018
2 parents e144fc3 + b7275b8 commit d64e25d
Show file tree
Hide file tree
Showing 131 changed files with 1,072 additions and 671 deletions.
76 changes: 76 additions & 0 deletions dredd/api-description.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,79 @@ definitions:
numWarnings:
description: Number of logged warnings
type: integer
postProcessing:
type: object
properties:
naming:
type: object
properties:
stripYear:
type: boolean
pattern:
type: string
multiEp:
type: integer
patternAirByDate:
type: string
patternSports:
type: string
patternAnime:
type: string
enableCustomNamingAirByDate:
type: boolean
enableCustomNamingSports:
type: boolean
enableCustomNamingAnime:
type: boolean
animeMultiEp:
type: integer
animeNamingType:
type: integer
seriesDownloadDir:
type: string
processAutomatically:
type: boolean
postponeIfSyncFiles:
type: boolean
postponeIfNoSubs:
type: boolean
renameEpisodes:
type: boolean
createMissingShowDirs:
type: boolean
addShowsWithoutDir:
type: boolean
moveAssociatedFiles:
type: boolean
nfoRename:
type: boolean
airdateEpisodes:
type: boolean
unpack:
type: boolean
deleteRarContent:
type: boolean
noDelete:
type: boolean
processMethod:
type: string
reflinkAvailable:
type: boolean
autoPostprocessorFrequency:
type: integer
syncFiles:
type: array
fileTimestampTimezone:
type: string
allowedExtensions:
type: array
extraScripts:
type: array
extraScriptsUrl:
type: string
multiEpStrings:
type: object

Log:
type: object
properties:
Expand Down Expand Up @@ -1834,6 +1907,9 @@ parameters:
type: string
enum:
- main
- statuses
- qualities
- metadata
log-level:
name: level
in: query
Expand Down
6 changes: 3 additions & 3 deletions medusa/clients/torrent/deluge_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,9 @@ def _set_torrent_ratio(self, result):

elif ratio and float(ratio) == -1:
# Disable stop at ratio to seed forever
post_data = json.dumps({"method": "core.set_torrent_stop_at_ratio",
"params": [result.hash, False],
"id": 5})
post_data = json.dumps({'method': 'core.set_torrent_stop_at_ratio',
'params': [result.hash, False],
'id': 5})

self._request(method='post', data=post_data)

Expand Down
2 changes: 1 addition & 1 deletion medusa/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def change_GIT_PATH():
"""
app.version_check_scheduler = None
app.version_check_scheduler = scheduler.Scheduler(
CheckVersion(), cycleTime=datetime.timedelta(hours=app.UPDATE_FREQUENCY), threadName="CHECKVERSION", silent=False)
CheckVersion(), cycleTime=datetime.timedelta(hours=app.UPDATE_FREQUENCY), threadName='CHECKVERSION', silent=False)
app.version_check_scheduler.enable = True
app.version_check_scheduler.start()
app.version_check_scheduler.forceRun()
Expand Down
2 changes: 1 addition & 1 deletion medusa/databases/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# coding=utf-8

from __future__ import unicode_literals
__all__ = ["main_db", "cache_db", "failed_db"]
__all__ = ['main_db', 'cache_db', 'failed_db']
98 changes: 49 additions & 49 deletions medusa/databases/cache_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
# and subclass the previous migration.
class InitialSchema(db.SchemaUpgrade):
def test(self):
return self.hasTable("db_version")
return self.hasTable('db_version')

def execute(self):
queries = [
("CREATE TABLE lastUpdate (provider TEXT, time NUMERIC);",),
("CREATE TABLE lastSearch (provider TEXT, time NUMERIC);",),
("CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer_id INTEGER,"
" show_name TEXT, season NUMERIC DEFAULT -1, custom NUMERIC DEFAULT 0);",),
("CREATE TABLE scene_names (indexer_id INTEGER, name TEXT);",),
("CREATE TABLE network_timezones (network_name TEXT PRIMARY KEY, timezone TEXT);",),
("CREATE TABLE scene_exceptions_refresh (list TEXT PRIMARY KEY, last_refreshed INTEGER);",),
("CREATE TABLE db_version (db_version INTEGER);",),
("INSERT INTO db_version(db_version) VALUES (1);",),
('CREATE TABLE lastUpdate (provider TEXT, time NUMERIC);',),
('CREATE TABLE lastSearch (provider TEXT, time NUMERIC);',),
('CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer_id INTEGER,'
' show_name TEXT, season NUMERIC DEFAULT -1, custom NUMERIC DEFAULT 0);',),
('CREATE TABLE scene_names (indexer_id INTEGER, name TEXT);',),
('CREATE TABLE network_timezones (network_name TEXT PRIMARY KEY, timezone TEXT);',),
('CREATE TABLE scene_exceptions_refresh (list TEXT PRIMARY KEY, last_refreshed INTEGER);',),
('CREATE TABLE db_version (db_version INTEGER);',),
('INSERT INTO db_version(db_version) VALUES (1);',),
]
for query in queries:
if len(query) == 1:
Expand All @@ -40,110 +40,110 @@ def execute(self):

class AddSceneExceptions(InitialSchema):
def test(self):
return self.hasTable("scene_exceptions")
return self.hasTable('scene_exceptions')

def execute(self):
self.connection.action(
"CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer_id INTEGER, show_name TEXT);")
'CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer_id INTEGER, show_name TEXT);')


class AddSceneNameCache(AddSceneExceptions):
def test(self):
return self.hasTable("scene_names")
return self.hasTable('scene_names')

def execute(self):
self.connection.action("CREATE TABLE scene_names (indexer_id INTEGER, name TEXT);")
self.connection.action('CREATE TABLE scene_names (indexer_id INTEGER, name TEXT);')


class AddNetworkTimezones(AddSceneNameCache):
def test(self):
return self.hasTable("network_timezones")
return self.hasTable('network_timezones')

def execute(self):
self.connection.action("CREATE TABLE network_timezones (network_name TEXT PRIMARY KEY, timezone TEXT);")
self.connection.action('CREATE TABLE network_timezones (network_name TEXT PRIMARY KEY, timezone TEXT);')


class AddLastSearch(AddNetworkTimezones):
def test(self):
return self.hasTable("lastSearch")
return self.hasTable('lastSearch')

def execute(self):
self.connection.action("CREATE TABLE lastSearch (provider TEXT, time NUMERIC);")
self.connection.action('CREATE TABLE lastSearch (provider TEXT, time NUMERIC);')


class AddSceneExceptionsSeasons(AddLastSearch):
def test(self):
return self.hasColumn("scene_exceptions", "season")
return self.hasColumn('scene_exceptions', 'season')

def execute(self):
self.addColumn("scene_exceptions", "season", "NUMERIC", -1)
self.addColumn('scene_exceptions', 'season', 'NUMERIC', -1)


class AddSceneExceptionsCustom(AddSceneExceptionsSeasons): # pylint:disable=too-many-ancestors
def test(self):
return self.hasColumn("scene_exceptions", "custom")
return self.hasColumn('scene_exceptions', 'custom')

def execute(self):
self.addColumn("scene_exceptions", "custom", "NUMERIC", 0)
self.addColumn('scene_exceptions', 'custom', 'NUMERIC', 0)


class AddSceneExceptionsRefresh(AddSceneExceptionsCustom): # pylint:disable=too-many-ancestors
def test(self):
return self.hasTable("scene_exceptions_refresh")
return self.hasTable('scene_exceptions_refresh')

def execute(self):
self.connection.action(
"CREATE TABLE scene_exceptions_refresh (list TEXT PRIMARY KEY, last_refreshed INTEGER);")
'CREATE TABLE scene_exceptions_refresh (list TEXT PRIMARY KEY, last_refreshed INTEGER);')


class ConvertSceneExeptionsToIndexerScheme(AddSceneExceptionsRefresh): # pylint:disable=too-many-ancestors
def test(self):
return self.hasColumn("scene_exceptions", "indexer_id")
return self.hasColumn('scene_exceptions', 'indexer_id')

def execute(self):
self.connection.action("DROP TABLE IF EXISTS tmp_scene_exceptions;")
self.connection.action("ALTER TABLE scene_exceptions RENAME TO tmp_scene_exceptions;")
self.connection.action("CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer_id INTEGER,"
" show_name TEXT, season NUMERIC DEFAULT -1, custom NUMERIC DEFAULT 0);")
self.connection.action("INSERT INTO scene_exceptions SELECT exception_id, tvdb_id as indexer_id, show_name,"
" season, custom FROM tmp_scene_exceptions;")
self.connection.action("DROP TABLE tmp_scene_exceptions;")
self.connection.action('DROP TABLE IF EXISTS tmp_scene_exceptions;')
self.connection.action('ALTER TABLE scene_exceptions RENAME TO tmp_scene_exceptions;')
self.connection.action('CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer_id INTEGER,'
' show_name TEXT, season NUMERIC DEFAULT -1, custom NUMERIC DEFAULT 0);')
self.connection.action('INSERT INTO scene_exceptions SELECT exception_id, tvdb_id as indexer_id, show_name,'
' season, custom FROM tmp_scene_exceptions;')
self.connection.action('DROP TABLE tmp_scene_exceptions;')


class ConvertSceneNamesToIndexerScheme(AddSceneExceptionsRefresh): # pylint:disable=too-many-ancestors
def test(self):
return self.hasColumn("scene_names", "indexer_id")
return self.hasColumn('scene_names', 'indexer_id')

def execute(self):
self.connection.action("DROP TABLE IF EXISTS tmp_scene_names;")
self.connection.action("ALTER TABLE scene_names RENAME TO tmp_scene_names;")
self.connection.action("CREATE TABLE scene_names (indexer_id INTEGER, name TEXT);")
self.connection.action("INSERT INTO scene_names SELECT * FROM tmp_scene_names;")
self.connection.action("DROP TABLE tmp_scene_names;")
self.connection.action('DROP TABLE IF EXISTS tmp_scene_names;')
self.connection.action('ALTER TABLE scene_names RENAME TO tmp_scene_names;')
self.connection.action('CREATE TABLE scene_names (indexer_id INTEGER, name TEXT);')
self.connection.action('INSERT INTO scene_names SELECT * FROM tmp_scene_names;')
self.connection.action('DROP TABLE tmp_scene_names;')


class RemoveIndexerUpdateSchema(ConvertSceneNamesToIndexerScheme): # pylint:disable=too-many-ancestors
def test(self):
return not self.hasTable("indexer_update")
return not self.hasTable('indexer_update')

def execute(self):
self.connection.action("DROP TABLE indexer_update;")
self.connection.action('DROP TABLE indexer_update;')


class AddIndexerSceneExceptions(RemoveIndexerUpdateSchema): # pylint:disable=too-many-ancestors
def test(self):
return self.hasColumn("scene_exceptions", "indexer")
return self.hasColumn('scene_exceptions', 'indexer')

def execute(self):
self.connection.action("DROP TABLE IF EXISTS tmp_scene_exceptions;")
self.connection.action("ALTER TABLE scene_exceptions RENAME TO tmp_scene_exceptions;")
self.connection.action('DROP TABLE IF EXISTS tmp_scene_exceptions;')
self.connection.action('ALTER TABLE scene_exceptions RENAME TO tmp_scene_exceptions;')
self.connection.action(
"CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer INTEGER, indexer_id INTEGER, "
"show_name TEXT, season NUMERIC DEFAULT -1, custom NUMERIC DEFAULT 0);")
'CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer INTEGER, indexer_id INTEGER, '
'show_name TEXT, season NUMERIC DEFAULT -1, custom NUMERIC DEFAULT 0);')
self.connection.action(
"INSERT INTO scene_exceptions SELECT exception_id, 1, indexer_id, show_name, season,"
"custom FROM tmp_scene_exceptions;")
self.connection.action("DROP TABLE tmp_scene_exceptions;")
'INSERT INTO scene_exceptions SELECT exception_id, 1, indexer_id, show_name, season,'
'custom FROM tmp_scene_exceptions;')
self.connection.action('DROP TABLE tmp_scene_exceptions;')


class AddIndexerIds(AddIndexerSceneExceptions):
Expand Down Expand Up @@ -196,5 +196,5 @@ def clear_provider_tables(self):
def inc_major_version(self):
major_version, minor_version = self.connection.version
major_version += 1
self.connection.action("UPDATE db_version SET db_version = ?;", [major_version])
self.connection.action('UPDATE db_version SET db_version = ?;', [major_version])
return self.connection.version
8 changes: 4 additions & 4 deletions medusa/databases/failed_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def translate_status(self):
def inc_major_version(self):
major_version, minor_version = self.connection.version
major_version += 1
self.connection.action("UPDATE db_version SET db_version = ?;", [major_version])
self.connection.action('UPDATE db_version SET db_version = ?;', [major_version])
return self.connection.version


Expand All @@ -185,16 +185,16 @@ def shift_history_qualities(self):
This makes it possible to set UNKNOWN as 1, making it the lowest quality.
"""
log.info('Shift qualities in history one place to the left.')
sql_results = self.connection.select("SELECT quality FROM history GROUP BY quality ORDER BY quality DESC;")
sql_results = self.connection.select('SELECT quality FROM history GROUP BY quality ORDER BY quality DESC;')
for result in sql_results:
quality = result[b'quality']
new_quality = quality << 1
self.connection.action(
"UPDATE history SET quality = ? WHERE quality = ?;",
'UPDATE history SET quality = ? WHERE quality = ?;',
[new_quality, quality]
)

def update_status_unknown(self):
"""Change any `UNKNOWN` quality to 1."""
log.info(u'Update status UNKONWN from tv_episodes')
self.connection.action("UPDATE history SET quality = 1 WHERE quality = 65536;")
self.connection.action('UPDATE history SET quality = 1 WHERE quality = 65536;')
Loading

0 comments on commit d64e25d

Please sign in to comment.