mirror of
https://github.com/morpheus65535/bazarr
synced 2025-01-03 05:25:28 +00:00
Adding audio language information to UI
This commit is contained in:
parent
b741b02f17
commit
a7bf4f9527
4 changed files with 44 additions and 10 deletions
|
@ -125,7 +125,7 @@ def series():
|
|||
offset = (int(page) - 1) * 15
|
||||
max_page = (missing_count / 15) + 1
|
||||
|
||||
c.execute("SELECT tvdbId, title, path_substitution(path), languages, hearing_impaired, sonarrSeriesId, poster FROM table_shows ORDER BY title ASC LIMIT 15 OFFSET ?", (offset,))
|
||||
c.execute("SELECT tvdbId, title, path_substitution(path), languages, hearing_impaired, sonarrSeriesId, poster, audio_language FROM table_shows ORDER BY title ASC LIMIT 15 OFFSET ?", (offset,))
|
||||
data = c.fetchall()
|
||||
c.execute("SELECT code2, name FROM table_settings_languages WHERE enabled = 1")
|
||||
languages = c.fetchall()
|
||||
|
|
|
@ -6,6 +6,8 @@ from get_general_settings import *
|
|||
from get_sonarr_settings import *
|
||||
|
||||
def update_series():
|
||||
get_profile_list()
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
@ -16,14 +18,12 @@ def update_series():
|
|||
# Get shows data from Sonarr
|
||||
url_sonarr_api_series = url_sonarr + "/api/series?apikey=" + apikey_sonarr
|
||||
r = requests.get(url_sonarr_api_series)
|
||||
shows_list = []
|
||||
|
||||
# Get current shows in DB
|
||||
current_shows_db = c.execute('SELECT tvdbId FROM table_shows').fetchall()
|
||||
current_shows_db_list = [x[0] for x in current_shows_db]
|
||||
current_shows_sonarr = []
|
||||
|
||||
# Parsing data returned from Sonarr
|
||||
for show in r.json():
|
||||
try:
|
||||
overview = unicode(show['overview'])
|
||||
|
@ -43,9 +43,10 @@ def update_series():
|
|||
current_shows_sonarr.append(show['tvdbId'])
|
||||
|
||||
# Update or insert shows list in database table
|
||||
result = c.execute('''UPDATE table_shows SET title = ?, path = ?, tvdbId = ?, sonarrSeriesId = ?, overview = ?, poster = ?, fanart = ? WHERE tvdbid = ?''', (show["title"],show["path"],show["tvdbId"],show["id"],overview,poster,fanart,show["tvdbId"]))
|
||||
if result.rowcount == 0:
|
||||
c.execute('''INSERT INTO table_shows(title, path, tvdbId, languages,`hearing_impaired`, sonarrSeriesId, overview, poster, fanart) VALUES (?,?,?,(SELECT languages FROM table_shows WHERE tvdbId = ?),(SELECT `hearing_impaired` FROM table_shows WHERE tvdbId = ?), ?, ?, ?, ?)''', (show["title"],show["path"],show["tvdbId"],show["tvdbId"],show["tvdbId"],show["id"],overview,poster,fanart))
|
||||
try:
|
||||
c.execute('''INSERT INTO table_shows(title, path, tvdbId, languages,`hearing_impaired`, sonarrSeriesId, overview, poster, fanart, `audio_language`) VALUES (?,?,?,(SELECT languages FROM table_shows WHERE tvdbId = ?),(SELECT `hearing_impaired` FROM table_shows WHERE tvdbId = ?), ?, ?, ?, ?, ?)''', (show["title"], show["path"], show["tvdbId"], show["tvdbId"], show["tvdbId"], show["id"], overview, poster, fanart, profile_id_to_language(show['qualityProfileId'])))
|
||||
except:
|
||||
c.execute('''UPDATE table_shows SET title = ?, path = ?, tvdbId = ?, sonarrSeriesId = ?, overview = ?, poster = ?, fanart = ?, `audio_language` = ? WHERE tvdbid = ?''', (show["title"],show["path"],show["tvdbId"],show["id"],overview,poster,fanart,profile_id_to_language(show['qualityProfileId']),show["tvdbId"]))
|
||||
|
||||
# Delete shows not in Sonarr anymore
|
||||
deleted_items = []
|
||||
|
@ -59,3 +60,19 @@ def update_series():
|
|||
|
||||
# Close database connection
|
||||
db.close()
|
||||
|
||||
def get_profile_list():
|
||||
# Get profiles data from Sonarr
|
||||
url_sonarr_api_series = url_sonarr + "/api/profile?apikey=" + apikey_sonarr
|
||||
profiles_json = requests.get(url_sonarr_api_series)
|
||||
global profiles_list
|
||||
profiles_list = []
|
||||
|
||||
# Parsing data returned from Sonarr
|
||||
for profile in profiles_json.json():
|
||||
profiles_list.append([profile['id'], profile['language'].capitalize()])
|
||||
|
||||
def profile_id_to_language(id):
|
||||
for profile in profiles_list:
|
||||
if id == profile[0]:
|
||||
return profile[1]
|
|
@ -20,6 +20,11 @@ if os.path.exists(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
|||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
c.execute('alter table table_shows add column "audio_language" "text"')
|
||||
except:
|
||||
pass
|
||||
|
||||
# Commit change to db
|
||||
db.commit()
|
||||
|
||||
|
|
|
@ -88,7 +88,8 @@
|
|||
<tr>
|
||||
<th class="sorted ascending">Name</th>
|
||||
<th>Path</th>
|
||||
<th>Language</th>
|
||||
<th>Audio language</th>
|
||||
<th>Subtitles language</th>
|
||||
<th>Hearing-impaired</th>
|
||||
<th class="no-sort"></th>
|
||||
</tr>
|
||||
|
@ -102,6 +103,7 @@
|
|||
<td>
|
||||
{{row[2]}}
|
||||
</td>
|
||||
<td>{{row[7]}}</td>
|
||||
<td>
|
||||
%subs_languages = ast.literal_eval(str(row[3]))
|
||||
%if subs_languages is not None:
|
||||
|
@ -120,7 +122,7 @@
|
|||
end
|
||||
end
|
||||
%>
|
||||
<div class="config ui inverted basic compact icon" data-tooltip="Edit series" data-inverted="" data-tvdbid="{{row[0]}}" data-title="{{row[1]}}" data-poster="{{row[6]}}" data-languages="{{!subs_languages_list}}" data-hearing-impaired="{{row[4]}}">
|
||||
<div class="config ui inverted basic compact icon" data-tooltip="Edit series" data-inverted="" data-tvdbid="{{row[0]}}" data-title="{{row[1]}}" data-poster="{{row[6]}}" data-languages="{{!subs_languages_list}}" data-hearing-impaired="{{row[4]}}" data-audio="{{row[7]}}">
|
||||
<i class="ui black configure icon"></i>
|
||||
</div>
|
||||
</td>
|
||||
|
@ -174,7 +176,15 @@
|
|||
<div class="ui grid">
|
||||
<div class="middle aligned row">
|
||||
<div class="right aligned five wide column">
|
||||
<label>Languages</label>
|
||||
<label>Audio languages</label>
|
||||
</div>
|
||||
<div class="nine wide column">
|
||||
<div id="series_audio_language"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="middle aligned row">
|
||||
<div class="right aligned five wide column">
|
||||
<label>Subtitle languages</label>
|
||||
</div>
|
||||
<div class="nine wide column">
|
||||
<select name="languages" id="series_languages" multiple="" class="ui fluid selection dropdown">
|
||||
|
@ -249,6 +259,8 @@
|
|||
$("#series_title").html($(this).data("title"));
|
||||
$("#series_poster").attr("src", "{{base_url}}image_proxy" + $(this).data("poster"));
|
||||
|
||||
$("#series_audio_language").html($(this).data("audio"));
|
||||
|
||||
$('#series_languages').dropdown('clear');
|
||||
var languages_array = eval($(this).data("languages"));
|
||||
$('#series_languages').dropdown('set selected',languages_array);
|
||||
|
|
Loading…
Reference in a new issue