Added episodefile and moviefile id to database for future use.

This commit is contained in:
Louis Vézina 2019-10-05 22:39:58 -04:00
parent 6616ecd592
commit 63d5037566
3 changed files with 27 additions and 7 deletions

View File

@ -4,6 +4,7 @@ import atexit
from get_args import args
from peewee import *
from playhouse.sqliteq import SqliteQueueDatabase
from playhouse.migrate import *
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.
results_timeout=30.0) # Max. time to wait for query to be executed.
migrator = SqliteMigrator(database)
@database.func('path_substitution')
def path_substitution(path):
@ -78,6 +81,11 @@ class TableEpisodes(BaseModel):
subtitles = TextField(null=True)
title = 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:
table_name = 'table_episodes'
@ -109,6 +117,11 @@ class TableMovies(BaseModel):
tmdb_id = TextField(column_name='tmdbId', primary_key=True, null=False)
video_codec = 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:
table_name = 'table_movies'

View File

@ -116,7 +116,8 @@ def sync_episodes():
'format': format,
'resolution': resolution,
'video_codec': videoCodec,
'audio_codec': audioCodec})
'audio_codec': audioCodec,
'episode_file_id': episode['episodeFile']['id']})
else:
episodes_to_add.append({'sonarr_series_id': episode['seriesId'],
'sonarr_episode_id': episode['id'],
@ -129,7 +130,8 @@ def sync_episodes():
'format': format,
'resolution': resolution,
'video_codec': videoCodec,
'audio_codec': audioCodec})
'audio_codec': audioCodec,
'episode_file_id': episode['episodeFile']['id']})
# Update existing episodes in DB
episode_in_db_list = []
@ -145,7 +147,8 @@ def sync_episodes():
TableEpisodes.format,
TableEpisodes.resolution,
TableEpisodes.video_codec,
TableEpisodes.audio_codec
TableEpisodes.audio_codec,
TableEpisodes.episode_file_id
).dicts()
for item in episodes_in_db:

View File

@ -156,7 +156,8 @@ def update_movies():
'video_codec': unicode(videoCodec),
'audio_codec': unicode(audioCodec),
'overview': unicode(overview),
'imdb_id': unicode(imdbId)})
'imdb_id': unicode(imdbId),
'movie_file_id': movie['movieFile']['id']})
else:
if movie_default_enabled is True:
movies_to_add.append({'radarr_id': movie["id"],
@ -180,7 +181,8 @@ def update_movies():
'video_codec': videoCodec,
'audio_codec': audioCodec,
'imdb_id': imdbId,
'forced': movie_default_forced})
'forced': movie_default_forced,
'movie_file_id': movie['movieFile']['id']})
else:
movies_to_add.append({'radarr_id': movie["id"],
'title': movie["title"],
@ -199,7 +201,8 @@ def update_movies():
'resolution': resolution,
'video_codec': videoCodec,
'audio_codec': audioCodec,
'imdb_id': imdbId})
'imdb_id': imdbId,
'movie_file_id': movie['movieFile']['id']})
else:
logging.error(
'BAZARR Radarr returned a movie without a file path: ' + movie["path"] + separator +
@ -225,7 +228,8 @@ def update_movies():
TableMovies.resolution,
TableMovies.video_codec,
TableMovies.audio_codec,
TableMovies.imdb_id
TableMovies.imdb_id,
TableMovies.movie_file_id
).dicts()
for item in movies_in_db: