1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-11-05 17:05:03 -05:00

Merge pull request #1322 from abeloin/patch-subtitle_flags

Fix subtitles display issues.
This commit is contained in:
Alexandre Beloin 2015-02-15 20:08:03 -05:00
commit 945e2b58db
4 changed files with 49 additions and 22 deletions

View File

@ -508,9 +508,11 @@
#if $sickbeard.USE_SUBTITLES and $show.subtitles:
<td class="col-subtitles" align="center">
#if $epResult["subtitles"]:
#for $sub_lang in subliminal.language.language_list([x.strip() for x in $epResult["subtitles"].split(',') if x != ""]):
#for $sub_lang in subliminal.language.language_list([x.strip() for x in $epResult["subtitles"].split(',')] if x != ""):
#if sub_lang.alpha2 != ""
<img src="$sbRoot/images/flags/${sub_lang.alpha2}.png" width="16" height="11" alt="${sub_lang}" />
#else
<img src="$sbRoot/images/flags/unknown.png" width="16" height="11" alt="Unknown" />
#end if
#end for
#end if

View File

@ -131,7 +131,11 @@
<td class="tvShow" width="35%"><a href="$sbRoot/home/displayShow?show=$hItem["showid"]#season-$hItem["season"]">$hItem["show_name"] - <%="S%02i" % int(hItem["season"])+"E%02i" % int(hItem["episode"]) %>#if "proper" in $hItem["resource"].lower() or "repack" in $hItem["resource"].lower() then ' <span class="quality Proper">Proper</span>' else ""#</a></td>
<td align="center" #if $curStatus == SUBTITLED then 'class="subtitles_column"' else ''#>
#if $curStatus == SUBTITLED:
<img width="16" height="11" style="vertical-align:middle;" src="$sbRoot/images/flags/<%= hItem["resource"][len(hItem["resource"])-6:len(hItem["resource"])-4]+'.png'%>">
#if $sickbeard.SUBTITLES_MULTI:
<img width="16" height="11" style="vertical-align:middle;" src="$sbRoot/images/flags/<%= hItem["resource"][len(hItem["resource"])-6:len(hItem["resource"])-4]+'.png'%>" onError="this.onerror=null;this.src='$sbRoot/images/flags/unknown.png';">
#else
<img width="16" height="11" style="vertical-align:middle;" src="$sbRoot/images/flags/unknown.png">
#end if
#end if
<span style="cursor: help; vertical-align:middle;" title="$os.path.basename($hItem["resource"])">$statusStrings[$curStatus]</span>
</td>

View File

@ -14,9 +14,9 @@
$.each(subtitles,function(index, language){
if (language != "" && language != "und") {
if (index != subtitles.length - 1) {
subtitles_td.append($("<img/>").attr({"src": sbRoot+"/images/flags/"+language+".png", "alt": language, "width": 16, "height": 11}).css({'padding-right' : '6px','padding-bottom' : '4px'}));
subtitles_td.append($("<img/>").attr({"src": sbRoot+"/images/flags/"+language+".png", "alt": language, "width": 16, "height": 11}));
} else {
subtitles_td.append($("<img/>").attr({"src": sbRoot+"/images/flags/"+language+".png", "alt": language, "width": 16, "height": 11}).css({'padding-bottom' : '4px'}));
subtitles_td.append($("<img/>").attr({"src": sbRoot+"/images/flags/"+language+".png", "alt": language, "width": 16, "height": 11}));
}
}
});

View File

@ -1390,6 +1390,7 @@ class TVEpisode(object):
self.episode), logger.DEBUG)
previous_subtitles = self.subtitles
added_subtitles = []
try:
need_languages = set(sickbeard.SUBTITLES_LANGUAGES) - set(self.subtitles)
@ -1407,19 +1408,25 @@ class TVEpisode(object):
helpers.chmodAsParent(subs_new_path)
for subtitle in subtitles.get(video):
added_subtitles.append(subtitle.language.alpha2)
new_file_path = ek.ek(os.path.join, subs_new_path, os.path.basename(subtitle.path))
helpers.moveFile(subtitle.path, new_file_path)
helpers.chmodAsParent(new_file_path)
else:
for video in subtitles:
for subtitle in subtitles.get(video):
added_subtitles.append(subtitle.language.alpha2)
helpers.chmodAsParent(subtitle.path)
except Exception as e:
logger.log("Error occurred when downloading subtitles: " + traceback.format_exc(), logger.ERROR)
return
if sickbeard.SUBTITLES_MULTI:
self.refreshSubtitles()
else:
self.subtitles = added_subtitles
self.subtitles_searchcount = self.subtitles_searchcount + 1 if self.subtitles_searchcount else 1 # added the if because sometime it raise an error
self.subtitles_lastsearch = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
self.saveToDB()
@ -1931,7 +1938,7 @@ class TVEpisode(object):
myDB = db.DBConnection()
rows = myDB.select(
'SELECT episode_id FROM tv_episodes WHERE showid = ? AND season = ? AND episode = ?',
'SELECT episode_id, subtitles FROM tv_episodes WHERE showid = ? AND season = ? AND episode = ?',
[self.show.indexerid, self.season, self.episode])
epID = None
@ -1940,6 +1947,8 @@ class TVEpisode(object):
if epID:
# use a custom update method to get the data into the DB for existing records.
# Multi or added subtitle or removed subtitles
if sickbeard.SUBTITLES_MULTI or not rows[0]['subtitles'] or not self.subtitles:
return [
"UPDATE tv_episodes SET indexerid = ?, indexer = ?, name = ?, description = ?, subtitles = ?, "
"subtitles_searchcount = ?, subtitles_lastsearch = ?, airdate = ?, hasnfo = ?, hastbn = ?, status = ?, "
@ -1950,6 +1959,18 @@ class TVEpisode(object):
self.hastbn,
self.status, self.location, self.file_size, self.release_name, self.is_proper, self.show.indexerid,
self.season, self.episode, self.absolute_number, self.version, self.release_group, epID]]
else:
# Don't update the subtitle language when the srt file doesn't contain the alpha2 code, keep value from subliminal
return [
"UPDATE tv_episodes SET indexerid = ?, indexer = ?, name = ?, description = ?, "
"subtitles_searchcount = ?, subtitles_lastsearch = ?, airdate = ?, hasnfo = ?, hastbn = ?, status = ?, "
"location = ?, file_size = ?, release_name = ?, is_proper = ?, showid = ?, season = ?, episode = ?, "
"absolute_number = ?, version = ?, release_group = ? WHERE episode_id = ?",
[self.indexerid, self.indexer, self.name, self.description,
self.subtitles_searchcount, self.subtitles_lastsearch, self.airdate.toordinal(), self.hasnfo,
self.hastbn,
self.status, self.location, self.file_size, self.release_name, self.is_proper, self.show.indexerid,
self.season, self.episode, self.absolute_number, self.version, self.release_group, epID]]
else:
# use a custom insert method to get the data into the DB.
return [