mirror of https://github.com/morpheus65535/bazarr
Added episodefile and moviefile id to database for future use.
This commit is contained in:
parent
6616ecd592
commit
63d5037566
|
@ -4,6 +4,7 @@ import atexit
|
||||||
from get_args import args
|
from get_args import args
|
||||||
from peewee import *
|
from peewee import *
|
||||||
from playhouse.sqliteq import SqliteQueueDatabase
|
from playhouse.sqliteq import SqliteQueueDatabase
|
||||||
|
from playhouse.migrate import *
|
||||||
|
|
||||||
from helper import path_replace, path_replace_movie, path_replace_reverse, path_replace_reverse_movie
|
from helper import path_replace, path_replace_movie, path_replace_reverse, path_replace_reverse_movie
|
||||||
|
|
||||||
|
@ -14,6 +15,8 @@ database = SqliteQueueDatabase(
|
||||||
queue_max_size=256, # Max. # of pending writes that can accumulate.
|
queue_max_size=256, # Max. # of pending writes that can accumulate.
|
||||||
results_timeout=30.0) # Max. time to wait for query to be executed.
|
results_timeout=30.0) # Max. time to wait for query to be executed.
|
||||||
|
|
||||||
|
migrator = SqliteMigrator(database)
|
||||||
|
|
||||||
|
|
||||||
@database.func('path_substitution')
|
@database.func('path_substitution')
|
||||||
def path_substitution(path):
|
def path_substitution(path):
|
||||||
|
@ -78,6 +81,11 @@ class TableEpisodes(BaseModel):
|
||||||
subtitles = TextField(null=True)
|
subtitles = TextField(null=True)
|
||||||
title = TextField(null=True)
|
title = TextField(null=True)
|
||||||
video_codec = TextField(null=True)
|
video_codec = TextField(null=True)
|
||||||
|
episode_file_id = IntegerField(null=True)
|
||||||
|
|
||||||
|
migrate(
|
||||||
|
migrator.add_column('table_episodes', 'episode_file_id', episode_file_id),
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
table_name = 'table_episodes'
|
table_name = 'table_episodes'
|
||||||
|
@ -109,6 +117,11 @@ class TableMovies(BaseModel):
|
||||||
tmdb_id = TextField(column_name='tmdbId', primary_key=True, null=False)
|
tmdb_id = TextField(column_name='tmdbId', primary_key=True, null=False)
|
||||||
video_codec = TextField(null=True)
|
video_codec = TextField(null=True)
|
||||||
year = TextField(null=True)
|
year = TextField(null=True)
|
||||||
|
movie_file_id = IntegerField(null=True)
|
||||||
|
|
||||||
|
migrate(
|
||||||
|
migrator.add_column('table_movies', 'movie_file_id', movie_file_id),
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
table_name = 'table_movies'
|
table_name = 'table_movies'
|
||||||
|
|
|
@ -116,7 +116,8 @@ def sync_episodes():
|
||||||
'format': format,
|
'format': format,
|
||||||
'resolution': resolution,
|
'resolution': resolution,
|
||||||
'video_codec': videoCodec,
|
'video_codec': videoCodec,
|
||||||
'audio_codec': audioCodec})
|
'audio_codec': audioCodec,
|
||||||
|
'episode_file_id': episode['episodeFile']['id']})
|
||||||
else:
|
else:
|
||||||
episodes_to_add.append({'sonarr_series_id': episode['seriesId'],
|
episodes_to_add.append({'sonarr_series_id': episode['seriesId'],
|
||||||
'sonarr_episode_id': episode['id'],
|
'sonarr_episode_id': episode['id'],
|
||||||
|
@ -129,7 +130,8 @@ def sync_episodes():
|
||||||
'format': format,
|
'format': format,
|
||||||
'resolution': resolution,
|
'resolution': resolution,
|
||||||
'video_codec': videoCodec,
|
'video_codec': videoCodec,
|
||||||
'audio_codec': audioCodec})
|
'audio_codec': audioCodec,
|
||||||
|
'episode_file_id': episode['episodeFile']['id']})
|
||||||
|
|
||||||
# Update existing episodes in DB
|
# Update existing episodes in DB
|
||||||
episode_in_db_list = []
|
episode_in_db_list = []
|
||||||
|
@ -145,7 +147,8 @@ def sync_episodes():
|
||||||
TableEpisodes.format,
|
TableEpisodes.format,
|
||||||
TableEpisodes.resolution,
|
TableEpisodes.resolution,
|
||||||
TableEpisodes.video_codec,
|
TableEpisodes.video_codec,
|
||||||
TableEpisodes.audio_codec
|
TableEpisodes.audio_codec,
|
||||||
|
TableEpisodes.episode_file_id
|
||||||
).dicts()
|
).dicts()
|
||||||
|
|
||||||
for item in episodes_in_db:
|
for item in episodes_in_db:
|
||||||
|
|
|
@ -156,7 +156,8 @@ def update_movies():
|
||||||
'video_codec': unicode(videoCodec),
|
'video_codec': unicode(videoCodec),
|
||||||
'audio_codec': unicode(audioCodec),
|
'audio_codec': unicode(audioCodec),
|
||||||
'overview': unicode(overview),
|
'overview': unicode(overview),
|
||||||
'imdb_id': unicode(imdbId)})
|
'imdb_id': unicode(imdbId),
|
||||||
|
'movie_file_id': movie['movieFile']['id']})
|
||||||
else:
|
else:
|
||||||
if movie_default_enabled is True:
|
if movie_default_enabled is True:
|
||||||
movies_to_add.append({'radarr_id': movie["id"],
|
movies_to_add.append({'radarr_id': movie["id"],
|
||||||
|
@ -180,7 +181,8 @@ def update_movies():
|
||||||
'video_codec': videoCodec,
|
'video_codec': videoCodec,
|
||||||
'audio_codec': audioCodec,
|
'audio_codec': audioCodec,
|
||||||
'imdb_id': imdbId,
|
'imdb_id': imdbId,
|
||||||
'forced': movie_default_forced})
|
'forced': movie_default_forced,
|
||||||
|
'movie_file_id': movie['movieFile']['id']})
|
||||||
else:
|
else:
|
||||||
movies_to_add.append({'radarr_id': movie["id"],
|
movies_to_add.append({'radarr_id': movie["id"],
|
||||||
'title': movie["title"],
|
'title': movie["title"],
|
||||||
|
@ -199,7 +201,8 @@ def update_movies():
|
||||||
'resolution': resolution,
|
'resolution': resolution,
|
||||||
'video_codec': videoCodec,
|
'video_codec': videoCodec,
|
||||||
'audio_codec': audioCodec,
|
'audio_codec': audioCodec,
|
||||||
'imdb_id': imdbId})
|
'imdb_id': imdbId,
|
||||||
|
'movie_file_id': movie['movieFile']['id']})
|
||||||
else:
|
else:
|
||||||
logging.error(
|
logging.error(
|
||||||
'BAZARR Radarr returned a movie without a file path: ' + movie["path"] + separator +
|
'BAZARR Radarr returned a movie without a file path: ' + movie["path"] + separator +
|
||||||
|
@ -225,7 +228,8 @@ def update_movies():
|
||||||
TableMovies.resolution,
|
TableMovies.resolution,
|
||||||
TableMovies.video_codec,
|
TableMovies.video_codec,
|
||||||
TableMovies.audio_codec,
|
TableMovies.audio_codec,
|
||||||
TableMovies.imdb_id
|
TableMovies.imdb_id,
|
||||||
|
TableMovies.movie_file_id
|
||||||
).dicts()
|
).dicts()
|
||||||
|
|
||||||
for item in movies_in_db:
|
for item in movies_in_db:
|
||||||
|
|
Loading…
Reference in New Issue