This commit is contained in:
Louis Vézina 2019-10-26 23:17:14 -04:00
parent 7c6f47738f
commit 277198685e
8 changed files with 73 additions and 78 deletions

View file

@ -1,5 +1,6 @@
import os
from sqlite3worker import Sqlite3Worker
from six import string_types
from get_args import args
from helper import path_replace, path_replace_movie, path_replace_reverse, path_replace_reverse_movie
@ -19,7 +20,7 @@ class SqliteDictConverter:
if type(values_dict) is dict:
for key, value in values_dict.items():
self.keys += key + ", "
if type(value) not in [str, unicode]:
if type(value) is not string_types:
value = str(value)
else:
value = "\"" + value + "\""
@ -46,6 +47,8 @@ class SqliteDictPathMapper:
item['path'] = path_replace(item['path'])
elif type(values_dict) is dict:
values_dict['path'] = path_replace(values_dict['path'])
else:
return path_replace(values_dict)
def path_replace_movie(self, values_dict):
if type(values_dict) is list:
@ -53,6 +56,8 @@ class SqliteDictPathMapper:
item['path'] = path_replace_movie(item['path'])
elif type(values_dict) is dict:
values_dict['path'] = path_replace_movie(values_dict['path'])
else:
return path_replace(values_dict)
dict_mapper = SqliteDictPathMapper()

View file

@ -913,8 +913,8 @@ def refine_from_db(path, video):
video.title = re.sub(r'(\(\d\d\d\d\))', '', data['title'])
if data['year']:
if int(data['year']) > 0: video.year = int(data['year'])
if data['imdb_id']: video.imdb_id = data['imdb_id']
video.alternative_titles = ast.literal_eval(data['alternative_titles'])
if data['imdbId']: video.imdb_id = data['imdbId']
video.alternative_titles = ast.literal_eval(data['alternativeTitles'])
if not video.format:
if data['format']: video.format = data['format']
if not video.resolution:

View file

@ -277,7 +277,7 @@ def list_missing_subtitles(no=None, epno=None):
def list_missing_subtitles_movies(no=None):
if no is not None:
movies_subtitles_clause = " WHERE radarrId=no"
movies_subtitles_clause = " WHERE radarrId=" + str(no)
else:
movies_subtitles_clause = ""
@ -325,7 +325,7 @@ def list_missing_subtitles_movies(no=None):
missing_subtitles_global.append(tuple([str(missing_subtitles), movie_subtitles['radarrId']]))
for missing_subtitles_item in missing_subtitles_global:
database.execute("UPDATE table_movies SET missing_subtitles=? WHERE radarrIr=?",
database.execute("UPDATE table_movies SET missing_subtitles=? WHERE radarrId=?",
(missing_subtitles_item[0], missing_subtitles_item[1]))

View file

@ -609,7 +609,7 @@ def search_json(query):
if settings.general.getboolean('use_radarr'):
# Get matching movies
movies = database.execute("SELECT title, radarrId, year FROM table_movies WEHRE title LIKE ? ORDER BY "
movies = database.execute("SELECT title, radarrId, year FROM table_movies WHERE title LIKE ? ORDER BY "
"title ASC", (query,))
for movie in movies:
search_list.append(dict([('name', re.sub(r'\ \(\d{4}\)', '', movie['title']) + ' (' + movie['year'] + ')'),
@ -741,9 +741,9 @@ def movies():
languages = database.execute("SELECT code2, name FROM table_settings_languages WHERE enabled=1")
return template('movies', bazarr_version=bazarr_version, rows=data, languages=languages,
missing_count=missing_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)
missing_count=missing_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)
@route(base_url + 'movieseditor')
@ -843,13 +843,9 @@ def movie(no):
"scenename, monitored, failedAttempts, forced FROM table_movies "
"WHERE radarrId=?", (no,), only_one=True)
# path_replace
dict_mapper.path_replace(movies_details)
dict_mapper.path_replace_movie(movies_details)
for movie_details in movies_details:
movies_details = movie_details
break
tmdbid = movies_details['tmdb_id']
tmdbid = movies_details['tmdbId']
languages = database.execute("SELECT code2, name FROM table_settings_languages WHERE enabled=1")

View file

@ -49,7 +49,7 @@ def get_notifier_providers():
def get_series_name(sonarrSeriesId):
data = database.execute("SELECT title FROM table_shows WHERE sonarrSeriesId=?", (sonarrSeriesId,), only_one=True)
return data[0]['title'] or None
return data['title'] or None
def get_episode_name(sonarrEpisodeId):

View file

@ -19,11 +19,11 @@
<meta name="msapplication-config" content="{{base_url}}static/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
<title>{{details.title}} - Bazarr</title>
<title>{{details['title']}} - Bazarr</title>
<style>
body {
background-color: #1b1c1d;
background-image: url("{{base_url}}image_proxy_movies{{details.fanart}}");
background-image: url("{{base_url}}image_proxy_movies{{details['fanart']}}");
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
@ -84,7 +84,7 @@
%from config import settings
%from helper import path_replace_movie
%single_language = settings.general.getboolean('single_language')
<div style="display: none;"><img src="{{base_url}}image_proxy_movies{{details.fanart}}"></div>
<div style="display: none;"><img src="{{base_url}}image_proxy_movies{{details['fanart']}}"></div>
<div id='loader' class="ui page dimmer">
<div id="loader_text" class="ui indeterminate text loader">Loading...</div>
</div>
@ -94,7 +94,7 @@
<div id="divdetails" class="ui container">
<div class="ui stackable grid">
<div class="three wide column">
<img class="left floated ui image" style="max-height:250px;" src="{{base_url}}image_proxy_movies{{details.poster}}">
<img class="left floated ui image" style="max-height:250px;" src="{{base_url}}image_proxy_movies{{details['poster']}}">
</div>
<div class="thirteen wide column">
@ -102,12 +102,12 @@
<div class="ui row">
<div class="twelve wide left aligned column">
<h2>
%if details.monitored == 'True':
%if details['monitored'] == 'True':
<span data-tooltip="Movie is Monitored in Radarr"><i class="bookmark icon"></i></span>
%else:
<span data-tooltip="Movie is not Monitored in Radarr"><i class="bookmark outline icon"></i></span>
%end
{{details.title}}
{{details['title']}}
</h2>
</div>
@ -116,7 +116,7 @@
<button id="scan_disk" class="ui button" data-tooltip="Scan Disk For Subtitles" data-inverted=""><i class="ui inverted large compact refresh icon"></i></button>
<button id="search_missing_subtitles_movie" class="ui button" data-tooltip="Download Missing Subtitles" data-inverted=""><i class="ui inverted huge compact search icon"></i></button>
<%
subs_languages = ast.literal_eval(str(details.languages))
subs_languages = ast.literal_eval(str(details['languages']))
subs_languages_list = []
if subs_languages is not None:
for subs_language in subs_languages:
@ -125,23 +125,23 @@
end
%>
%if subs_languages is not None:
<button class="manual_search ui button" data-tooltip="Manually Search For Subtitles" data-inverted="" data-moviePath="{{details.path}}" data-scenename="{{details.scene_name}}" data-language="{{subs_languages_list}}" data-hi="{{details.hearing_impaired}}" data-forced="{{details.forced}}" data-movie_title="{{details.title}}" data-radarrId="{{details.radarr_id}}"><i class="ui inverted large compact user icon"></i></button>
<button class="manual_upload ui button" data-tooltip="Upload Subtitle File" data-inverted="" data-moviePath="{{details.path}}" data-scenename="{{details.scene_name}}" data-language="{{subs_languages_list}}" data-hi="{{details.hearing_impaired}}" data-movie_title="{{details.forced}}" data-radarrId="{{details.title}}"><i class="ui inverted large compact cloud upload icon"></i></button>
<button class="manual_search ui button" data-tooltip="Manually Search For Subtitles" data-inverted="" data-moviePath="{{details['path']}}" data-scenename="{{details['sceneName']}}" data-language="{{subs_languages_list}}" data-hi="{{details['hearing_impaired']}}" data-forced="{{details['forced']}}" data-movie_title="{{details['title']}}" data-radarrId="{{details['radarrId']}}"><i class="ui inverted large compact user icon"></i></button>
<button class="manual_upload ui button" data-tooltip="Upload Subtitle File" data-inverted="" data-moviePath="{{details['path']}}" data-scenename="{{details['sceneName']}}" data-language="{{subs_languages_list}}" data-hi="{{details['hearing_impaired']}}" data-movie_title="{{details['forced']}}" data-radarrId="{{details['title']}}"><i class="ui inverted large compact cloud upload icon"></i></button>
%end
<button id="config" class="ui button" data-tooltip="Edit Movie" data-inverted="" data-tmdbid="{{details.tmdb_id}}" data-title="{{details.title}}" data-poster="{{details.poster}}" data-audio="{{details.audio_language}}" data-languages="{{!subs_languages_list}}" data-hearing-impaired="{{details.hearing_impaired}}" data-forced="{{details.forced}}"><i class="ui inverted large compact configure icon"></i></button>
<button id="config" class="ui button" data-tooltip="Edit Movie" data-inverted="" data-tmdbid="{{details['tmdbId']}}" data-title="{{details['title']}}" data-poster="{{details['poster']}}" data-audio="{{details['audio_language']}}" data-languages="{{!subs_languages_list}}" data-hearing-impaired="{{details['hearing_impaired']}}" data-forced="{{details['forced']}}"><i class="ui inverted large compact configure icon"></i></button>
</div>
</div>
</div>
<div class="ui row">
{{details.overview}}
{{details['overview']}}
</div>
<div class="ui row">
<div class="ui tiny inverted label" style='background-color: #777777;'>{{details.audio_language}}</div>
<div class="ui tiny inverted label" style='background-color: #35c5f4;'>{{details.path}}</div>
% if details.scene_name is not None:
<div class="ui tiny inverted label" style='background-color: orange;'>{{details.scene_name}}</div>
<div class="ui tiny inverted label" style='background-color: #777777;'>{{details['audio_language']}}</div>
<div class="ui tiny inverted label" style='background-color: #35c5f4;'>{{details['path']}}</div>
% if details['sceneName'] is not None:
<div class="ui tiny inverted label" style='background-color: orange;'>{{details['sceneName']}}</div>
% end
</div>
@ -152,8 +152,8 @@
</div>
<div class="ui row" style="padding-top: 0em;">
<div class="ui tiny inverted label" style='background-color: #777777;'>Hearing-impaired: {{details.hearing_impaired}}</div>
<div class="ui tiny inverted label" style='background-color: #777777;'>Forced: {{details.forced}}</div>
<div class="ui tiny inverted label" style='background-color: #777777;'>Hearing-impaired: {{details['hearing_impaired']}}</div>
<div class="ui tiny inverted label" style='background-color: #777777;'>Forced: {{details['forced']}}</div>
</div>
</div>
</div>
@ -170,7 +170,7 @@
</thead>
<tbody>
<%
subtitles_files = ast.literal_eval(str(details.subtitles))
subtitles_files = ast.literal_eval(str(details['subtitles']))
subtitles_files.sort()
if subtitles_files is not None:
for subtitles_file in subtitles_files:
@ -189,7 +189,7 @@
<td><div class="ui tiny inverted label" style='background-color: #777777;'>{{language_from_alpha2(subtitles_file[0].split(':')[0])}}{{' forced' if forced else ''}}</div></td>
<td>
%if subtitles_file[1] is not None:
<a class="remove_subtitles ui inverted basic compact icon" data-tooltip="Delete Subtitle File" data-inverted="" data-position="top right" data-moviePath="{{details.path}}" data-subtitlesPath="{{path_replace_movie(subtitles_file[1])}}" data-language="{{alpha3_from_alpha2(subtitles_file[0].split(':')[0])}}" data-radarrId={{details.radarr_id}}>
<a class="remove_subtitles ui inverted basic compact icon" data-tooltip="Delete Subtitle File" data-inverted="" data-position="top right" data-moviePath="{{details['path']}}" data-subtitlesPath="{{path_replace_movie(subtitles_file[1])}}" data-language="{{alpha3_from_alpha2(subtitles_file[0].split(':')[0])}}" data-radarrId={{details['radarrId']}}>
<i class="ui black delete icon"></i>
</a>
%end
@ -207,8 +207,8 @@
</tbody>
</table>
<%
if details.missing_subtitles is not None:
missing_subs_languages = ast.literal_eval(details.missing_subtitles)
if details['missing_subtitles'] is not None:
missing_subs_languages = ast.literal_eval(details['missing_subtitles'])
else:
missing_subs_languages = []
end
@ -232,17 +232,17 @@
forced_bool = False
end
if details.failed_attempts is not None and settings.general.getboolean('adaptive_searching') and missing_subs_language in details.failed_attempts:
for lang in ast.literal_eval(details.failed_attempts):
if details['failed_attempts'] is not None and settings.general.getboolean('adaptive_searching') and missing_subs_language in details['failed_attempts']:
for lang in ast.literal_eval(details['failed_attempts']):
if missing_subs_language in lang:
if search_active(lang[1]):
%>
<a class="get_subtitle ui small blue label" data-moviePath="{{details.path}}" data-scenename="{{details.scene_name}}" data-language="{{alpha3_from_alpha2(str(missing_subs_language.split(':')[0]))}}" data-hi="{{details.hearing_impaired}}" data-forced="{{details.forced}}" data-radarrId={{details.radarr_id}}>
<a class="get_subtitle ui small blue label" data-moviePath="{{details['path']}}" data-scenename="{{details['sceneName']}}" data-language="{{alpha3_from_alpha2(str(missing_subs_language.split(':')[0]))}}" data-hi="{{details['hearing_impaired']}}" data-forced="{{details['forced']}}" data-radarrId={{details['radarrId']}}>
{{language_from_alpha2(str(missing_subs_language.split(':')[0]))}}{{' forced' if forced else ''}}
<i style="margin-left:3px; margin-right:0" class="search icon"></i>
</a>
%else:
<a data-tooltip="Automatic Searching Delayed (Adaptive Search)" data-position="top left" data-inverted="" class="get_subtitle ui small red label" data-moviePath="{{details.path}}" data-scenename="{{details.scene_name}}" data-language="{{alpha3_from_alpha2(str(missing_subs_language.split(':')[0]))}}" data-hi="{{details.hearing_impaired}}" data-forced="{{details.forced}}" data-radarrId={{details.radarr_id}}>
<a data-tooltip="Automatic Searching Delayed (Adaptive Search)" data-position="top left" data-inverted="" class="get_subtitle ui small red label" data-moviePath="{{details['path']}}" data-scenename="{{details['sceneName']}}" data-language="{{alpha3_from_alpha2(str(missing_subs_language.split(':')[0]))}}" data-hi="{{details['hearing_impaired']}}" data-forced="{{details['forced']}}" data-radarrId={{details['radarrId']}}>
{{language_from_alpha2(str(missing_subs_language.split(':')[0]))}}{{' forced' if forced else ''}}
<i style="margin-left:3px; margin-right:0" class="search icon"></i>
</a>
@ -252,7 +252,7 @@
end
else:
%>
<a class="get_subtitle ui small blue label" data-moviePath="{{details.path}}" data-scenename="{{details.scene_name}}" data-language="{{alpha3_from_alpha2(str(missing_subs_language.split(':')[0]))}}" data-hi="{{details.hearing_impaired}}" data-forced="{{details.forced}}" data-radarrId={{details.radarr_id}}>
<a class="get_subtitle ui small blue label" data-moviePath="{{details['path']}}" data-scenename="{{details['sceneName']}}" data-language="{{alpha3_from_alpha2(str(missing_subs_language.split(':')[0]))}}" data-hi="{{details['hearing_impaired']}}" data-forced="{{details['forced']}}" data-radarrId={{details['radarrId']}}>
{{language_from_alpha2(str(missing_subs_language.split(':')[0]))}}{{' forced' if forced else ''}}
<i style="margin-left:3px; margin-right:0" class="search icon"></i>
</a>
@ -297,7 +297,7 @@
<option value="None">None</option>
%end
%for language in languages:
<option value="{{language.code2}}">{{language.name}}</option>
<option value="{{language['code2']}}">{{language['name']}}</option>
%end
</select>
</div>
@ -353,7 +353,7 @@
<th style="text-align: left;">Provider:</th>
<th style="text-align: left;">Matching:</th>
<th style="text-align: left;">Releases:</th>
<th></th>
<th></th>details
</tr>
</thead>
</table>
@ -467,7 +467,7 @@
forced: $(this).attr("data-forced"),
radarrId: $(this).attr("data-radarrId"),
tmdbid: {{tmdbid}},
title: "{{!details.title.replace("'", "\\'")}}"
title: "{{!details['title'].replace("'", "\\'")}}"
};
$('#loader_text').text("Downloading Subtitle File...");
@ -541,7 +541,7 @@
hi: hi,
forced: forced,
radarrId: radarrId,
title: "{{!details.title.replace("'", "\'")}}"
title: "{{!details['title'].replace("'", "\'")}}"
};
$('#search_result').DataTable( {
@ -647,7 +647,7 @@
sceneName = $(this).attr("data-sceneName");
language = $(this).attr("data-language");
radarrId = $(this).attr("data-radarrId");
var title = "{{!details.title.replace("'", "\'")}}";
var title = "{{!details['title'].replace("'", "\'")}}";
$('#language').dropdown();
@ -674,7 +674,7 @@
language: $(button).attr("data-language"),
hi: hi,
radarrId: radarrId,
title: "{{!details.title.replace("'", "\\'")}}"
title: "{{!details['title'].replace("'", "\\'")}}"
};
$('#loader_text').text("Downloading Subtitle File...");

View file

@ -71,38 +71,38 @@
%for row in rows:
<tr class="selectable">
<td>
%if row.monitored == "True":
%if row['monitored'] == "True":
<span data-tooltip="Movie monitored in Radarr" data-inverted="" data-position="top left"><i class="bookmark icon"></i></span>
%else:
<span data-tooltip="Movie unmonitored in Radarr" data-inverted="" data-position="top left"><i class="bookmark outline icon"></i></span>
%end
</td>
<td>
% if row.scene_name is not None:
<span data-tooltip="Scenename is: {{row.scene_name}}" data-inverted='' data-position="top left"><i class="info circle icon"></i></span>
% if row['sceneName'] is not None:
<span data-tooltip="Scenename is: {{row['sceneName']}}" data-inverted='' data-position="top left"><i class="info circle icon"></i></span>
% end
<a href="{{base_url}}movie/{{row.radarr_id}}">{{row.title}}</a>
<a href="{{base_url}}movie/{{row['radarrId']}}">{{row['title']}}</a>
</td>
<td>
%if os.path.isfile(row.path):
%if os.path.isfile(row['path']):
<span data-tooltip="This path seems to be valid." data-inverted="" data-position="top left"><i class="checkmark icon"></i></span>
%else:
<span data-tooltip="This path doesn't seem to be valid." data-inverted="" data-position="top left"><i class="warning sign icon"></i></span>
%end
{{row.path}}
{{row['path']}}
</td>
<td>{{row.audio_language}}</td>
<td>{{row['audio_language']}}</td>
<td>
%subs_languages = ast.literal_eval(str(row.languages))
%subs_languages = ast.literal_eval(str(row['languages']))
%if subs_languages is not None:
%for subs_language in subs_languages:
<div class="ui tiny label">{{subs_language}}</div>
%end
%end
</td>
<td>{{!"" if row.hearing_impaired is None else row.hearing_impaired}}</td>
<td>{{row.forced}}</td>
<td {{!"style='background-color: #e8e8e8;'" if row.hearing_impaired is None else ""}}>
<td>{{!"" if row['hearing_impaired'] is None else row['hearing_impaired']}}</td>
<td>{{row['forced']}}</td>
<td {{!"style='background-color: #e8e8e8;'" if row['hearing_impaired'] is None else ""}}>
<%
subs_languages_list = []
if subs_languages is not None:
@ -111,7 +111,7 @@
end
end
%>
<div class="config ui inverted basic compact icon" data-tooltip="Edit Movie" data-inverted="" data-position="top right" data-no="{{row.radarr_id}}" data-title="{{row.title}}" data-poster="{{row.poster}}" data-languages="{{!subs_languages_list}}" data-forced="{{row.forced}}" data-hearing-impaired="{{row.hearing_impaired}}" data-audio="{{row.audio_language}}">
<div class="config ui inverted basic compact icon" data-tooltip="Edit Movie" data-inverted="" data-position="top right" data-no="{{row['radarrId']}}" data-title="{{row['title']}}" data-poster="{{row['poster']}}" data-languages="{{!subs_languages_list}}" data-forced="{{row['forced']}}" data-hearing-impaired="{{row['hearing_impaired']}}" data-audio="{{row['audio_language']}}">
<i class="ui black configure icon"></i>
</div>
</td>
@ -187,7 +187,7 @@
<option value="None">None</option>
%end
%for language in languages:
<option value="{{language.code2}}">{{language.name}}</option>
<option value="{{language['code2']}}">{{language['name']}}</option>
%end
</select>
</div>

View file

@ -44,30 +44,24 @@
% from get_args import args
% import os
% from database import TableEpisodes, TableMovies, System
% from database import database
% import operator
% from config import settings
%episodes_missing_subtitles_clause = [
% (TableEpisodes.missing_subtitles != '[]')
%]
%if settings.sonarr.getboolean('only_monitored'):
% episodes_missing_subtitles_clause.append(
% (TableEpisodes.monitored == 'True')
% )
%if settings.sonarr.getboolean('only_monitored'):
% episodes_missing_subtitles_clause = " AND monitored='True'"
%else:
% episodes_missing_subtitles_clause = ""
%end
%movies_missing_subtitles_clause = [
% (TableMovies.missing_subtitles != '[]')
%]
%if settings.radarr.getboolean('only_monitored'):
% movies_missing_subtitles_clause.append(
% (TableMovies.monitored == 'True')
% )
%if settings.radarr.getboolean('only_monitored'):
% episodes_missing_subtitles_clause_movie = " AND monitored='True'"
%else:
% episodes_missing_subtitles_clause_movie = ""
%end
% wanted_series = TableEpisodes.select().where(reduce(operator.and_, episodes_missing_subtitles_clause)).count()
% wanted_movies = TableMovies.select().where(reduce(operator.and_, movies_missing_subtitles_clause)).count()
% wanted_series = len(database.execute("SELECT COUNT(*) FROM table_episodes WHERE missing_subtitles != '[]'" + episodes_missing_subtitles_clause))
% wanted_movies = len(database.execute("SELECT COUNT(*) FROM table_movies WHERE missing_subtitles != '[]'" + episodes_missing_subtitles_clause_movie))
<div id='loader' class="ui page dimmer">
<div id="loader_text" class="ui indeterminate text loader">Loading...</div>