mirror of
https://github.com/morpheus65535/bazarr
synced 2025-01-03 05:25:28 +00:00
Continuing development
This commit is contained in:
parent
122ec09f9a
commit
184d2b47e9
5 changed files with 44 additions and 32 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1 +1,3 @@
|
|||
*.pyc
|
||||
bazarr.db
|
||||
cachefile.dbm
|
||||
|
|
BIN
bazarr.db
BIN
bazarr.db
Binary file not shown.
23
bazarr.py
23
bazarr.py
|
@ -17,6 +17,7 @@ from get_languages import *
|
|||
from get_general_settings import *
|
||||
from get_sonarr_settings import *
|
||||
from list_subtitles import *
|
||||
from get_subtitle import *
|
||||
|
||||
@route('/static/:path#.+#', name='static')
|
||||
def static(path):
|
||||
|
@ -24,7 +25,6 @@ def static(path):
|
|||
|
||||
@route('/image_proxy/<url:path>', method='GET')
|
||||
def image_proxy(url):
|
||||
print url_sonarr_short + url
|
||||
img_pil = Image.open(BytesIO(requests.get(url_sonarr_short + '/' + url).content))
|
||||
img_buffer = BytesIO()
|
||||
img_pil.tobytes()
|
||||
|
@ -78,7 +78,7 @@ def episodes(no):
|
|||
c = conn.cursor()
|
||||
|
||||
series_details = []
|
||||
series_details = c.execute("SELECT title, overview, poster, fanart FROM table_shows WHERE sonarrSeriesId LIKE ?", (str(no),)).fetchone()
|
||||
series_details = c.execute("SELECT title, overview, poster, fanart, hearing_impaired FROM table_shows WHERE sonarrSeriesId LIKE ?", (str(no),)).fetchone()
|
||||
|
||||
sqlite3.enable_callback_tracebacks(True)
|
||||
episodes = c.execute("SELECT title, path_substitution(path), season, episode, subtitles, sonarrSeriesId, missing_subtitles(path) FROM table_episodes WHERE sonarrSeriesId LIKE ?", (str(no),)).fetchall()
|
||||
|
@ -133,22 +133,23 @@ def remove_subtitles():
|
|||
|
||||
try:
|
||||
os.remove(subtitlesPath)
|
||||
store_subtitles(episodePath)
|
||||
redirect('/episodes/' + sonarrSeriesId)
|
||||
except OSError:
|
||||
redirect('/episodes/' + sonarrSeriesId + '?error=1')
|
||||
pass
|
||||
store_subtitles(episodePath)
|
||||
redirect('/episodes/' + sonarrSeriesId)
|
||||
|
||||
@route('/remove_subtitles', method='GET')
|
||||
def remove_subtitles():
|
||||
@route('/get_subtitle', method='GET')
|
||||
def get_subtitle():
|
||||
episodePath = request.GET.episodePath
|
||||
subtitlesPath = request.GET.subtitlesPath
|
||||
language = request.GET.language
|
||||
hi = request.GET.hi
|
||||
sonarrSeriesId = request.GET.sonarrSeriesId
|
||||
|
||||
|
||||
try:
|
||||
os.remove(subtitlesPath)
|
||||
download_subtitle(episodePath, language, hi, None)
|
||||
store_subtitles(episodePath)
|
||||
redirect('/episodes/' + sonarrSeriesId)
|
||||
except OSError:
|
||||
redirect('/episodes/' + sonarrSeriesId + '?error=1')
|
||||
redirect('/episodes/' + sonarrSeriesId + '?error=2')
|
||||
|
||||
run(host=ip, port=port)
|
||||
|
|
15
get_subtitle.py
Normal file
15
get_subtitle.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
import os
|
||||
from babelfish import *
|
||||
from subliminal import *
|
||||
|
||||
# configure the cache
|
||||
region.configure('dogpile.cache.dbm', arguments={'filename': 'cachefile.dbm'})
|
||||
|
||||
def download_subtitle(path, language, hi, providers):
|
||||
video = scan_video(path)
|
||||
best_subtitles = download_best_subtitles([video], {Language(language)}, providers=providers, hearing_impaired=hi)
|
||||
best_subtitle = best_subtitles[video][0]
|
||||
|
||||
return save_subtitles(video, [best_subtitle])
|
||||
|
||||
#download_subtitle('Z:\Series TV\Vikings\Season 03\Vikings.S03E03.720p.HDTV.x264-KILLERS.mkv', 'fra', False, None)
|
|
@ -75,6 +75,8 @@
|
|||
</head>
|
||||
<body>
|
||||
%import ast
|
||||
%import pycountry
|
||||
%from get_general_settings import *
|
||||
<div style="display: none;"><img src="/image_proxy{{details[3]}}"></div>
|
||||
<div id='loader' class="ui page dimmer">
|
||||
<div class="ui indeterminate text loader">Loading...</div>
|
||||
|
@ -144,7 +146,6 @@
|
|||
<th>Title</th>
|
||||
<th class="collapsing">Existing subtitles</th>
|
||||
<th class="collapsing">Missing subtitles</th>
|
||||
<th class="no-sort"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -156,17 +157,16 @@
|
|||
%actual_languages = ast.literal_eval(episode[4])
|
||||
%if actual_languages is not None:
|
||||
%for language in actual_languages:
|
||||
|
||||
%if language[1] is not None:
|
||||
<a href="/remove_subtitles?episodePath={{episode[1]}}&subtitlesPath={{language[1]}}&sonarrSeriesId={{episode[5]}}" class="ui tiny label">
|
||||
{{language[0]}}
|
||||
<i class="delete icon"></i>
|
||||
</a>
|
||||
%else:
|
||||
<div class="ui tiny label">
|
||||
{{language[0]}}
|
||||
</div>
|
||||
%end
|
||||
%if language[1] is not None:
|
||||
<a href="/remove_subtitles?episodePath={{episode[1]}}&subtitlesPath={{path_replace(language[1])}}&sonarrSeriesId={{episode[5]}}" class="ui tiny label">
|
||||
{{language[0]}}
|
||||
<i class="delete icon"></i>
|
||||
</a>
|
||||
%else:
|
||||
<div class="ui tiny label">
|
||||
{{language[0]}}
|
||||
</div>
|
||||
%end
|
||||
%end
|
||||
%end
|
||||
</td>
|
||||
|
@ -174,19 +174,13 @@
|
|||
%missing_languages = ast.literal_eval(episode[6])
|
||||
%if missing_languages is not None:
|
||||
%for language in missing_languages:
|
||||
<div class="ui tiny label">
|
||||
<a href="/get_subtitle?episodePath={{episode[1]}}&language={{pycountry.languages.lookup(str(language)).alpha_3}}&hi={{details[4]}}&sonarrSeriesId={{episode[5]}}" class="ui tiny label">
|
||||
{{language}}
|
||||
</div>
|
||||
<i class="search icon"></i>
|
||||
</a>
|
||||
%end
|
||||
%end
|
||||
</td>
|
||||
<td class="collapsing">
|
||||
%if len(missing_languages) > 0:
|
||||
<div class="ui inverted basic compact icon" data-tooltip="Download missing subtitles" data-inverted="" onclick="location.href='/edit_series/{{episode[3]}}';">
|
||||
<i class="ui black download icon"></i>
|
||||
</div>
|
||||
%end
|
||||
</td>
|
||||
</tr>
|
||||
%end
|
||||
</tbody>
|
||||
|
|
Loading…
Reference in a new issue