@ -22,7 +22,7 @@ from calendar import day_name
from get_args import args
from init import *
from database import database
from database import database , dict_mapper
from notifier import update_notifier
from logger import configure_logging , empty_log
@ -517,19 +517,20 @@ def redirect_root():
def series ( ) :
authorize ( )
missing_count = database . execute ( " SELECT COUNT(*) FROM table_shows " )
series_count = len ( database . execute ( " SELECT COUNT(*) FROM table_shows " ) )
page = request . GET . page
if page == " " :
page = " 1 "
page_size = int ( settings . general . page_size )
offset = ( int ( page ) - 1 ) * page_size
max_page = int ( math . ceil ( missing _count / ( page_size + 0.0 ) ) )
max_page = int ( math . ceil ( series _count / ( page_size + 0.0 ) ) )
# Get list of series
# path_replace
data = database . execute ( " SELECT tvdbId, title, path, languages, hearing_impaired, sonarrSeriesId, poster, "
" audio_language, forced FROM table_shows ORDER BY sortTitle ASC LIMIT ? OFFSET ? " ,
( page_size , offset ) )
# path_replace
dict_mapper . path_replace ( data )
# Get languages list
languages = database . execute ( " SELECT code2, name FROM table_settings_languages WHERE enabled=1 " )
@ -542,7 +543,7 @@ def series():
# Get missing subtitles count by series
missing_subtitles_list = database . execute ( " SELECT table_shows.sonarrSeriesId, "
" COUNT(table_episodes.missing_subtitles) FROM table_shows LEFT JOIN "
" COUNT(table_episodes.missing_subtitles) as missing_subtitles FROM table_shows LEFT JOIN "
" table_episodes ON table_shows.sonarrSeriesId= "
" table_episodes.sonarrSeriesId WHERE table_shows.languages IS NOT ' None ' "
" AND table_episodes.missing_subtitles IS NOT ' [] ' " +
@ -556,13 +557,13 @@ def series():
# Get total subtitles count by series
total_subtitles_list = database . execute ( " SELECT table_shows.sonarrSeriesId, "
" COUNT(table_episodes.missing_subtitles) FROM table_shows LEFT JOIN "
" COUNT(table_episodes.missing_subtitles) as missing_subtitles FROM table_shows LEFT JOIN "
" table_episodes ON table_shows.sonarrSeriesId= "
" table_episodes.sonarrSeriesId WHERE table_shows.languages IS NOT ' None ' "
+ total_subtitles_clause + " GROUP BY table_shows.sonarrSeriesId " )
return template ( ' series ' , bazarr_version = bazarr_version , rows = data , missing_subtitles_list = missing_subtitles_list ,
total_subtitles_list = total_subtitles_list , languages = languages , missing_count = missing _count,
total_subtitles_list = total_subtitles_list , languages = languages , missing_count = series _count,
page = page , max_page = max_page , base_url = base_url ,
single_language = settings . general . getboolean ( ' single_language ' ) , page_size = page_size ,
current_port = settings . general . port )
@ -577,9 +578,10 @@ def serieseditor():
missing_count = database . execute ( " SELECT COUNT(*) FROM table_shows " )
# Get series list
# path_replace
data = database . execute ( " SELECT tvdbId, title, path, languages, hearing_impaired, sonarrSeriesId, poster, "
" audio_language, forced FROM table_shows ORDER BY sortTitle ASC " )
# path_replace
dict_mapper . path_replace ( data )
# Get languages list
languages = database . execute ( " SELECT code2, name FROM table_settings_languages WHERE enabled=1 " )
@ -690,26 +692,29 @@ def edit_serieseditor():
def episodes ( no ) :
authorize ( )
# path_replace
series_details = database . execute ( " SELECT title, overview, poster, fanart, hearing_impaired, tvdbId, "
" audio_language, languages, path, forced FROM table_shows WHERE "
" sonarrSeriesId=? " , ( no , ) )
# path_replace
dict_mapper . path_replace ( series_details )
for series in series_details :
tvdbid = series . tvdb_id
tvdbid = series [ ' tvdbId ' ]
series_details = series
break
# path_replace
episodes = database . execute ( " SELECT title, path, season, episode, subtitles, sonarrSeriesId, missing_subtitles, "
" sonarrEpisodeId, scene_name, monitored, failedAttempts FROM table_episodes WHERE "
" sonarrSeriesId=? ORDER BY season DESC, episode DESC " , ( no , ) )
# path_replace
dict_mapper . path_replace ( episodes )
number = len ( episodes )
languages = database . execute ( " SELECT code2, name FROM table_settings_languages WHERE enabled=1 " )
seasons_list = [ ]
for key , season in itertools . groupby ( episodes . dicts ( ) , lambda x : x [ ' season ' ] ) :
for key , season in itertools . groupby ( episodes , lambda x : x [ ' season ' ] ) :
seasons_list . append ( list ( season ) )
return template ( ' episodes ' , bazarr_version = bazarr_version , no = no , details = series_details ,
@ -730,10 +735,11 @@ def movies():
offset = ( int ( page ) - 1 ) * page_size
max_page = int ( math . ceil ( missing_count / ( page_size + 0.0 ) ) )
# path_replace_movie
data = database . execute ( " SELECT tmdbId, title, path, languages, hearing_impaired, radarrId, poster, "
" audio_language, monitored, scenename, forced FROM table_movies ORDER BY sortTitle ASC "
" LIMIT ? OFFSET ? " , ( page_size , offset ) )
# path_replace
dict_mapper . path_replace_movie ( data )
languages = database . execute ( " SELECT code2, name FROM table_settings_languages WHERE enabled=1 " )
@ -750,9 +756,10 @@ def movieseditor():
missing_count = database . execute ( " SELECT COUNT(*) FORM table_movies " )
# path_replace_movie
data = database . execute ( " SELECT tmdbId, title, path, languages, hearing_impaired, radarrId, poster, "
" audio_language, forced FROM table_movies ORDER BY sortTitle ASC " )
# path_replace
dict_mapper . path_replace_movie ( data )
languages = database . execute ( " SELECT code2, name FROM table_settings_languages WHERE enabled=1 " )
@ -834,11 +841,12 @@ def edit_movie(no):
def movie ( no ) :
authorize ( )
# path_replace_movie
movies_details = database . execute ( " SELECT title, overview, poster, fanart, hearing_impaired, tmdbId, "
" audio_language, languages, path, subtitles, radarrId, missing_subtitles, "
" scenename, monitored, failedAttempts, forced FROM table_movies "
" WHERE radarrId=? " , ( no , ) )
# path_replace
dict_mapper . path_replace ( movies_details )
for movie_details in movies_details :
movies_details = movie_details
@ -1085,7 +1093,6 @@ def wantedseries():
offset = ( int ( page ) - 1 ) * page_size
max_page = int ( math . ceil ( missing_count / ( page_size + 0.0 ) ) )
# path_replace
data = database . execute ( " SELECT table_shows.title, table_episodes.season || ' x ' || table_episodes.episode, "
" table_episodes.title, table_episodes.missing_subtitles, table_episodes.sonarrSeriesId, "
" table_episodes.path, table_shows.hearing_impaired, table_episodes.sonarrEpisodeId, "
@ -1093,6 +1100,8 @@ def wantedseries():
" INNER JOIN table_shows on table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId "
" WHERE table_episodes.missing_subtitles != ' [] ' " + monitored_only_query_string +
" ORDER BY table_episodes._rowid_ DESC LIMIT ? OFFSET ? " , ( page_size , offset ) )
# path_replace
dict_mapper . path_replace ( data )
return template ( ' wantedseries ' , bazarr_version = bazarr_version , rows = data , missing_count = missing_count , page = page ,
max_page = max_page , base_url = base_url , page_size = page_size , current_port = settings . general . port )
@ -1117,11 +1126,12 @@ def wantedmovies():
offset = ( int ( page ) - 1 ) * page_size
max_page = int ( math . ceil ( missing_count / ( page_size + 0.0 ) ) )
# path_replace_movie
data = database . execute ( " SELECT title, missing_subtitles, radarrId, path, hearing_impaired, sceneName, "
" failedAttempts FROM table_movies WHERE missing_subtitles != ' [] ' " +
monitored_only_query_string + " ORDER BY _rowid_ DESC LIMIT ? OFFSET ? " ,
( page_size , offset ) )
# path_replace
dict_mapper . path_replace_movie ( data )
return template ( ' wantedmovies ' , bazarr_version = bazarr_version , rows = data ,
missing_count = missing_count , page = page , max_page = max_page , base_url = base_url , page_size = page_size ,