mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-04-23 22:27:17 -04:00
Initial commit
This commit is contained in:
parent
0bfe8b279b
commit
ea9d18903c
8 changed files with 777 additions and 3 deletions
61
bazarr.py
61
bazarr.py
|
@ -1,4 +1,4 @@
|
|||
bazarr_version = '0.4.1'
|
||||
bazarr_version = '0.4.5 dev'
|
||||
|
||||
import gc
|
||||
gc.enable()
|
||||
|
@ -59,6 +59,8 @@ from update_modules import *
|
|||
from bottle import route, run, template, static_file, request, redirect, response
|
||||
import bottle
|
||||
bottle.TEMPLATE_PATH.insert(0,os.path.join(os.path.dirname(__file__), 'views/'))
|
||||
bottle.debug(True)
|
||||
bottle.TEMPLATES.clear()
|
||||
|
||||
from json import dumps
|
||||
import itertools
|
||||
|
@ -129,6 +131,18 @@ def image_proxy(url):
|
|||
img_buffer.seek(0)
|
||||
return send_file(img_buffer, ctype=img_pil.format)
|
||||
|
||||
@route(base_url + 'image_proxy_movies/<url:path>', method='GET')
|
||||
def image_proxy_movies(url):
|
||||
from get_radarr_settings import get_radarr_settings
|
||||
url_radarr_short = get_radarr_settings()[1]
|
||||
|
||||
img_pil = Image.open(BytesIO(requests.get(url_radarr_short + '/' + url).content))
|
||||
img_buffer = BytesIO()
|
||||
img_pil.tobytes()
|
||||
img_pil.save(img_buffer, img_pil.format)
|
||||
img_buffer.seek(0)
|
||||
return send_file(img_buffer, ctype=img_pil.format)
|
||||
|
||||
@route(base_url)
|
||||
def series():
|
||||
import update_db
|
||||
|
@ -272,6 +286,51 @@ def episodes(no):
|
|||
|
||||
return template('episodes', __file__=__file__, bazarr_version=bazarr_version, no=no, details=series_details, languages=languages, seasons=seasons_list, url_sonarr_short=url_sonarr_short, base_url=base_url, tvdbid=tvdbid, number=number)
|
||||
|
||||
@route(base_url + 'movies')
|
||||
def movies():
|
||||
import update_db
|
||||
single_language = get_general_settings()[7]
|
||||
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db.create_function("path_substitution", 1, path_replace)
|
||||
c = db.cursor()
|
||||
|
||||
c.execute("SELECT COUNT(*) FROM table_movies")
|
||||
missing_count = c.fetchone()
|
||||
missing_count = missing_count[0]
|
||||
page = request.GET.page
|
||||
if page == "":
|
||||
page = "1"
|
||||
offset = (int(page) - 1) * 15
|
||||
max_page = int(math.ceil(missing_count / 15.0))
|
||||
|
||||
c.execute("SELECT tmdbId, title, path_substitution(path), languages, hearing_impaired, radarrId, poster, audio_language FROM table_movies 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()
|
||||
c.close()
|
||||
output = template('movies', __file__=__file__, bazarr_version=bazarr_version, rows=data, languages=languages, missing_count=missing_count, page=page, max_page=max_page, base_url=base_url, single_language=single_language)
|
||||
return output
|
||||
|
||||
@route(base_url + 'movie/<no:int>', method='GET')
|
||||
def movie(no):
|
||||
from get_radarr_settings import get_radarr_settings
|
||||
single_language = get_general_settings()[7]
|
||||
url_radarr_short = get_radarr_settings()[1]
|
||||
|
||||
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn.create_function("path_substitution", 1, path_replace)
|
||||
c = conn.cursor()
|
||||
|
||||
movies_details = []
|
||||
movies_details = c.execute("SELECT title, overview, poster, fanart, hearing_impaired, tmdbid, audio_language, languages, path_substitution(path) FROM table_movies WHERE radarrId LIKE ?", (str(no),)).fetchone()
|
||||
tmdbid = movies_details[5]
|
||||
|
||||
languages = c.execute("SELECT code2, name FROM table_settings_languages WHERE enabled = 1").fetchall()
|
||||
c.close()
|
||||
|
||||
return template('movie', __file__=__file__, bazarr_version=bazarr_version, no=no, details=movies_details, languages=languages, url_radarr_short=url_radarr_short, base_url=base_url, tmdbid=tmdbid)
|
||||
|
||||
@route(base_url + 'scan_disk/<no:int>', method='GET')
|
||||
def scan_disk(no):
|
||||
ref = request.environ['HTTP_REFERER']
|
||||
|
|
91
get_movies.py
Normal file
91
get_movies.py
Normal file
|
@ -0,0 +1,91 @@
|
|||
import os
|
||||
import sqlite3
|
||||
import requests
|
||||
|
||||
from get_general_settings import *
|
||||
|
||||
def update_movies():
|
||||
from get_radarr_settings import get_radarr_settings
|
||||
url_radarr = get_radarr_settings()[0]
|
||||
url_radarr_short = get_radarr_settings()[1]
|
||||
apikey_radarr = get_radarr_settings()[2]
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
if apikey_radarr == None:
|
||||
pass
|
||||
else:
|
||||
get_profile_list()
|
||||
|
||||
# Get movies data from radarr
|
||||
url_radarr_api_movies = url_radarr + "/api/movie?apikey=" + apikey_radarr
|
||||
r = requests.get(url_radarr_api_movies)
|
||||
|
||||
# Get current movies in DB
|
||||
current_movies_db = c.execute('SELECT tmdbId FROM table_movies').fetchall()
|
||||
current_movies_db_list = [x[0] for x in current_movies_db]
|
||||
current_movies_radarr = []
|
||||
|
||||
for movie in r.json():
|
||||
if movie['hasFile'] is True:
|
||||
try:
|
||||
overview = unicode(movie['overview'])
|
||||
except:
|
||||
overview = ""
|
||||
try:
|
||||
poster_big = movie['images'][0]['url']
|
||||
poster = os.path.splitext(poster_big)[0] + '-250' + os.path.splitext(poster_big)[1]
|
||||
except:
|
||||
poster = ""
|
||||
try:
|
||||
fanart = movie['images'][1]['url']
|
||||
except:
|
||||
fanart = ""
|
||||
|
||||
# Add movies in radarr to current movies list
|
||||
current_movies_radarr.append(unicode(movie['tmdbId']))
|
||||
|
||||
# Update or insert movies list in database table
|
||||
try:
|
||||
c.execute('''INSERT INTO table_movies(title, path, tmdbId, languages,`hearing_impaired`, radarrId, overview, poster, fanart, `audio_language`) VALUES (?,?,?,(SELECT languages FROM table_movies WHERE tmdbId = ?),(SELECT `hearing_impaired` FROM table_movies WHERE tmdbId = ?), ?, ?, ?, ?, ?)''', (movie["title"], os.path.join(movie["path"], movie['movieFile']['relativePath']), movie["tmdbId"], movie["tmdbId"], movie["tmdbId"], movie["id"], overview, poster, fanart, profile_id_to_language(movie['qualityProfileId'])))
|
||||
except:
|
||||
c.execute('''UPDATE table_movies SET title = ?, path = ?, tmdbId = ?, radarrId = ?, overview = ?, poster = ?, fanart = ?, `audio_language` = ? WHERE tmdbid = ?''', (movie["title"],os.path.join(movie["path"], movie['movieFile']['relativePath']),movie["tmdbId"],movie["id"],overview,poster,fanart,profile_id_to_language(movie['qualityProfileId']),movie["tmdbId"]))
|
||||
|
||||
# Delete movies not in radarr anymore
|
||||
deleted_items = []
|
||||
for item in current_movies_db_list:
|
||||
if item not in current_movies_radarr:
|
||||
deleted_items.append(tuple([item]))
|
||||
c.executemany('DELETE FROM table_movies WHERE tmdbId = ?',deleted_items)
|
||||
|
||||
# Commit changes to database table
|
||||
db.commit()
|
||||
|
||||
# Close database connection
|
||||
db.close()
|
||||
|
||||
def get_profile_list():
|
||||
from get_radarr_settings import get_radarr_settings
|
||||
url_radarr = get_radarr_settings()[0]
|
||||
url_radarr_short = get_radarr_settings()[1]
|
||||
apikey_radarr = get_radarr_settings()[2]
|
||||
|
||||
# Get profiles data from radarr
|
||||
url_radarr_api_movies = url_radarr + "/api/profile?apikey=" + apikey_radarr
|
||||
profiles_json = requests.get(url_radarr_api_movies)
|
||||
global profiles_list
|
||||
profiles_list = []
|
||||
|
||||
# Parsing data returned from radarr
|
||||
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]
|
||||
|
||||
if __name__ == '__main__':
|
||||
update_movies()
|
40
get_radarr_settings.py
Normal file
40
get_radarr_settings.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
import sqlite3
|
||||
import os
|
||||
import ast
|
||||
|
||||
def get_radarr_settings():
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Get Radarr API URL from database config table
|
||||
c.execute('''SELECT * FROM table_settings_radarr''')
|
||||
config_radarr = c.fetchone()
|
||||
|
||||
# Close database connection
|
||||
db.close()
|
||||
|
||||
# Build radarr URL
|
||||
ip_radarr = config_radarr[0]
|
||||
port_radarr = str(config_radarr[1])
|
||||
baseurl_radarr = config_radarr[2]
|
||||
ssl_radarr = config_radarr[3]
|
||||
apikey_radarr = config_radarr[4]
|
||||
full_update = config_radarr[5]
|
||||
|
||||
if ssl_radarr == 1:
|
||||
protocol_radarr = "https"
|
||||
else:
|
||||
protocol_radarr = "http"
|
||||
|
||||
if baseurl_radarr == None:
|
||||
baseurl_radarr = "/"
|
||||
if baseurl_radarr.startswith("/") == False:
|
||||
baseurl_radarr = "/" + baseurl_radarr
|
||||
if baseurl_radarr.endswith("/"):
|
||||
baseurl_radarr = baseurl_radarr[:-1]
|
||||
|
||||
url_radarr = protocol_radarr + "://" + ip_radarr + ":" + port_radarr + baseurl_radarr
|
||||
url_radarr_short = protocol_radarr + "://" + ip_radarr + ":" + port_radarr
|
||||
|
||||
return [url_radarr, url_radarr_short, apikey_radarr, full_update]
|
|
@ -60,7 +60,55 @@ def store_subtitles(file):
|
|||
c_db.close()
|
||||
|
||||
return actual_subtitles
|
||||
|
||||
|
||||
|
||||
def store_subtitles_movie(file):
|
||||
languages = []
|
||||
actual_subtitles = []
|
||||
if os.path.exists(file):
|
||||
if os.path.splitext(file)[1] == '.mkv':
|
||||
try:
|
||||
with open(file, 'rb') as f:
|
||||
mkv = enzyme.MKV(f)
|
||||
|
||||
for subtitle_track in mkv.subtitle_tracks:
|
||||
try:
|
||||
actual_subtitles.append([str(pycountry.languages.lookup(subtitle_track.language).alpha_2), None])
|
||||
except:
|
||||
pass
|
||||
except:
|
||||
pass
|
||||
|
||||
subtitles = core.search_external_subtitles(file)
|
||||
|
||||
for subtitle, language in subtitles.iteritems():
|
||||
if str(language) != 'und':
|
||||
actual_subtitles.append([str(language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))])
|
||||
else:
|
||||
with open(path_replace(os.path.join(os.path.dirname(file), subtitle)), 'r') as f:
|
||||
text = list(islice(f, 100))
|
||||
text = ' '.join(text)
|
||||
encoding = UnicodeDammit(text)
|
||||
try:
|
||||
text = text.decode(encoding.original_encoding)
|
||||
except Exception as e:
|
||||
logging.exception('Error trying to detect character encoding for this subtitles file: ' + path_replace(os.path.join(os.path.dirname(file), subtitle)) + ' You should try to delete this subtitles file manually and ask Bazarr to download it again.')
|
||||
else:
|
||||
detected_language = langdetect.detect(text)
|
||||
if len(detected_language) > 0:
|
||||
actual_subtitles.append([str(detected_language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))])
|
||||
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
|
||||
c_db.execute("UPDATE table_movies SET subtitles = ? WHERE path = ?", (str(actual_subtitles), path_replace_reverse(file)))
|
||||
conn_db.commit()
|
||||
|
||||
c_db.close()
|
||||
|
||||
return actual_subtitles
|
||||
|
||||
|
||||
def list_missing_subtitles(*no):
|
||||
query_string = ''
|
||||
try:
|
||||
|
@ -106,6 +154,13 @@ def full_scan_subtitles():
|
|||
for episode in episodes:
|
||||
store_subtitles(path_replace(episode[0]))
|
||||
|
||||
c_db = conn_db.cursor()
|
||||
movies = c_db.execute("SELECT path FROM table_movies").fetchall()
|
||||
c_db.close()
|
||||
|
||||
for movie in movies:
|
||||
store_subtitles_movie(path_replace(movie[0]))
|
||||
|
||||
gc.collect()
|
||||
|
||||
def series_scan_subtitles(no):
|
||||
|
|
13
update_db.py
13
update_db.py
|
@ -82,6 +82,19 @@ if os.path.exists(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
|||
else:
|
||||
c.execute('UPDATE table_settings_sonarr SET full_update="Daily"')
|
||||
|
||||
try:
|
||||
c.execute('CREATE TABLE "table_settings_radarr" ( `ip` TEXT NOT NULL, `port` INTEGER NOT NULL, `base_url` TEXT, `ssl` INTEGER, `apikey` TEXT , "full_update" "text")')
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
db.commit()
|
||||
c.execute('INSERT INTO `table_settings_radarr` (ip,port,base_url,ssl,apikey,full_update) VALUES ("127.0.0.1",7878,"/","False",Null,"Daily")')
|
||||
|
||||
try:
|
||||
c.execute('CREATE TABLE "table_movies" ( `tmdbId` TEXT NOT NULL UNIQUE, `title` TEXT NOT NULL, `path` TEXT NOT NULL UNIQUE, `languages` TEXT, `subtitles` TEXT, `missing_subtitles` TEXT, `hearing_impaired` TEXT, `radarrId` INTEGER NOT NULL UNIQUE, `overview` TEXT, `poster` TEXT, `fanart` TEXT, "audio_language" "text", `sceceName` TEXT, PRIMARY KEY(`tmdbId`) )')
|
||||
except:
|
||||
pass
|
||||
|
||||
# Commit change to db
|
||||
db.commit()
|
||||
|
||||
|
|
|
@ -39,12 +39,16 @@
|
|||
<div class="ui grid">
|
||||
<div class="row">
|
||||
<div class="sixteen wide column">
|
||||
<div class="ui inverted borderless labeled icon massive menu five item">
|
||||
<div class="ui inverted borderless labeled icon massive menu six item">
|
||||
<div class="ui container">
|
||||
<a class="item" href="{{base_url}}">
|
||||
<i class="play icon"></i>
|
||||
Series
|
||||
</a>
|
||||
<a class="item" href="{{base_url}}movies">
|
||||
<i class="film icon"></i>
|
||||
Movies
|
||||
</a>
|
||||
<a class="item" href="{{base_url}}history">
|
||||
<i class="wait icon"></i>
|
||||
History
|
||||
|
|
254
views/movie.tpl
Normal file
254
views/movie.tpl
Normal file
|
@ -0,0 +1,254 @@
|
|||
<html>
|
||||
<head>
|
||||
<!DOCTYPE html>
|
||||
<script src="{{base_url}}static/jquery/jquery-latest.min.js"></script>
|
||||
<script src="{{base_url}}static/semantic/semantic.min.js"></script>
|
||||
<script src="{{base_url}}static/jquery/tablesort.js"></script>
|
||||
<link rel="stylesheet" href="{{base_url}}static/semantic/semantic.min.css">
|
||||
|
||||
<link rel="apple-touch-icon" sizes="120x120" href="{{base_url}}static/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="{{base_url}}static/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="{{base_url}}static/favicon-16x16.png">
|
||||
<link rel="manifest" href="{{base_url}}static/manifest.json">
|
||||
<link rel="mask-icon" href="{{base_url}}static/safari-pinned-tab.svg" color="#5bbad5">
|
||||
<link rel="shortcut icon" href="{{base_url}}static/favicon.ico">
|
||||
<meta name="msapplication-config" content="{{base_url}}static/browserconfig.xml">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
|
||||
<title>{{details[0]}} - Bazarr</title>
|
||||
<style>
|
||||
body {
|
||||
background-color: #1b1c1d;
|
||||
background-image: url("{{base_url}}image_proxy{{details[3]}}");
|
||||
background-repeat: no-repeat;
|
||||
background-attachment: fixed;
|
||||
background-size: cover;
|
||||
background-position:center center;
|
||||
}
|
||||
#divdetails {
|
||||
background-color: #000000;
|
||||
opacity: 0.9;
|
||||
color: #ffffff;
|
||||
margin-top: 6em;
|
||||
margin-bottom: 3em;
|
||||
padding: 2em;
|
||||
border-radius: 1px;
|
||||
box-shadow: 0px 0px 5px 5px #000000;
|
||||
min-height: calc(250px + 4em);
|
||||
}
|
||||
#fondblanc {
|
||||
background-color: #ffffff;
|
||||
opacity: 0.9;
|
||||
border-radius: 1px;
|
||||
box-shadow: 0px 0px 3px 3px #ffffff;
|
||||
margin-top: 32px;
|
||||
margin-bottom: 3em;
|
||||
padding-top: 2em;
|
||||
padding-left: 2em;
|
||||
padding-right: 2em;
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
.ui.basic.button:hover, .ui.basic.buttons .button:hover {
|
||||
background: transparent !important;
|
||||
}
|
||||
.ui.basic.button:active, .ui.basic.buttons .button:active {
|
||||
background: transparent !important;
|
||||
}
|
||||
.ui.basic.button:focus, .ui.basic.buttons .button:focus {
|
||||
background: transparent !important;
|
||||
}
|
||||
.ui.basic.button:visited, .ui.basic.buttons .button:visited {
|
||||
background: transparent !important;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
%import ast
|
||||
%import pycountry
|
||||
%from get_general_settings import *
|
||||
%single_language = get_general_settings()[7]
|
||||
<div style="display: none;"><img src="{{base_url}}image_proxy{{details[3]}}"></div>
|
||||
<div id='loader' class="ui page dimmer">
|
||||
<div class="ui indeterminate text loader">Loading...</div>
|
||||
</div>
|
||||
% include('menu.tpl')
|
||||
|
||||
<div style='padding-left: 2em; padding-right: 2em;' class='ui container'>
|
||||
<div id="divdetails" class="ui container">
|
||||
<img class="left floated ui image" src="{{base_url}}image_proxy_movies{{details[2]}}">
|
||||
<div class="ui right floated basic icon buttons">
|
||||
<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" 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[7]))
|
||||
subs_languages_list = []
|
||||
if subs_languages is not None:
|
||||
for subs_language in subs_languages:
|
||||
subs_languages_list.append(subs_language)
|
||||
end
|
||||
end
|
||||
%>
|
||||
<button id="config" class="ui button" data-tooltip="Edit movie" data-inverted="" data-tmdbid="{{details[5]}}" data-title="{{details[0]}}" data-poster="{{details[2]}}" data-audio="{{details[6]}}" data-languages="{{!subs_languages_list}}" data-hearing-impaired="{{details[4]}}"><i class="ui inverted large compact configure icon"></i></button>
|
||||
</div>
|
||||
<h2>{{details[0]}}</h2>
|
||||
<p>{{details[1]}}</p>
|
||||
<p style='margin-top: 3em;'>
|
||||
<div class="ui tiny inverted label" style='background-color: #777777;'>{{details[6]}}</div>
|
||||
<div class="ui tiny inverted label" style='background-color: #35c5f4;'>{{details[8]}}</div>
|
||||
</p>
|
||||
<p style='margin-top: 2em;'>
|
||||
%for language in subs_languages_list:
|
||||
<div class="ui tiny inverted label" style='background-color: #35c5f4;'>{{language}}</div>
|
||||
%end
|
||||
</p>
|
||||
<div style='clear:both;'></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ui small modal">
|
||||
<i class="close icon"></i>
|
||||
<div class="header">
|
||||
<div id="movie_title"></div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<form name="movie_form" id="movie_form" action="" method="post" class="ui form">
|
||||
<div class="ui grid">
|
||||
<div class="four wide column">
|
||||
<img id="movie_poster" class="ui image" src="">
|
||||
</div>
|
||||
<div class="twelve wide column">
|
||||
<div class="ui grid">
|
||||
<div class="middle aligned row">
|
||||
<div class="right aligned five wide column">
|
||||
<label>Audio language</label>
|
||||
</div>
|
||||
<div class="nine wide column">
|
||||
<div id="movie_audio_language"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="middle aligned row">
|
||||
<div class="right aligned five wide column">
|
||||
<label>Subtitles languages</label>
|
||||
</div>
|
||||
<div class="nine wide column">
|
||||
<select name="languages" id="movie_languages" {{!'multiple="" ' if single_language == 'False' else ''}} class="ui fluid selection dropdown">
|
||||
<option value="">Languages</option>
|
||||
%for language in languages:
|
||||
<option value="{{language[0]}}">{{language[1]}}</option>
|
||||
%end
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="middle aligned row">
|
||||
<div class="right aligned five wide column">
|
||||
<label>Hearing-impaired</label>
|
||||
</div>
|
||||
<div class="nine wide column">
|
||||
<div id="movie_hearing-impaired_div" class="ui toggle checkbox">
|
||||
<input name="hearing_impaired" id="movie_hearing-impaired" type="checkbox">
|
||||
<label></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="ui cancel button" >Cancel</button>
|
||||
<button type="submit" name="save" value="save" form="movie_form" class="ui blue approve button">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
% include('footer.tpl')
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<script>
|
||||
$('#scan_disk').click(function(){
|
||||
window.location = '{{base_url}}scan_disk/{{no}}';
|
||||
})
|
||||
|
||||
$('#search_missing_subtitles').click(function(){
|
||||
window.location = '{{base_url}}search_missing_subtitles/{{no}}';
|
||||
})
|
||||
|
||||
$('.remove_subtitles').click(function(){
|
||||
var values = {
|
||||
episodePath: $(this).attr("data-episodePath"),
|
||||
language: $(this).attr("data-language"),
|
||||
subtitlesPath: $(this).attr("data-subtitlesPath"),
|
||||
sonarrmovieId: $(this).attr("data-sonarrmovieId"),
|
||||
sonarrEpisodeId: $(this).attr("data-sonarrEpisodeId"),
|
||||
tmdbid: {{tmdbid}}
|
||||
};
|
||||
$.ajax({
|
||||
url: "{{base_url}}remove_subtitles",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: values
|
||||
});
|
||||
$(document).ajaxStart(function(){
|
||||
$('#loader').addClass('active');
|
||||
});
|
||||
$(document).ajaxStop(function(){
|
||||
window.location.reload();
|
||||
});
|
||||
})
|
||||
|
||||
$('.get_subtitle').click(function(){
|
||||
var values = {
|
||||
episodePath: $(this).attr("data-episodePath"),
|
||||
sceneName: $(this).attr("data-sceneName"),
|
||||
language: $(this).attr("data-language"),
|
||||
hi: $(this).attr("data-hi"),
|
||||
sonarrmovieId: $(this).attr("data-sonarrmovieId"),
|
||||
sonarrEpisodeId: $(this).attr("data-sonarrEpisodeId"),
|
||||
tmdbid: {{tmdbid}}
|
||||
};
|
||||
$.ajax({
|
||||
url: "{{base_url}}get_subtitle",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: values
|
||||
});
|
||||
$(document).ajaxStart(function(){
|
||||
$('#loader').addClass('active');
|
||||
});
|
||||
$(document).ajaxStop(function(){
|
||||
window.location.reload();
|
||||
});
|
||||
})
|
||||
|
||||
$('a, i').click(function(){
|
||||
$('#loader').addClass('active');
|
||||
})
|
||||
|
||||
$('.modal')
|
||||
.modal({
|
||||
autofocus: false
|
||||
})
|
||||
;
|
||||
|
||||
$('#config').click(function(){
|
||||
$('#movie_form').attr('action', '{{base_url}}edit_movie/{{no}}');
|
||||
|
||||
$("#movie_title").html($(this).data("title"));
|
||||
$("#movie_poster").attr("src", "{{base_url}}image_proxy_movies" + $(this).data("poster"));
|
||||
|
||||
$("#movie_audio_language").html($(this).data("audio"));
|
||||
|
||||
$('#movie_languages').dropdown('clear');
|
||||
var languages_array = eval($(this).data("languages"));
|
||||
$('#movie_languages').dropdown('set selected',languages_array);
|
||||
|
||||
if ($(this).data("hearing-impaired") == "True") {
|
||||
$("#movie_hearing-impaired_div").checkbox('check');
|
||||
} else {
|
||||
$("#movie_hearing-impaired_div").checkbox('uncheck');
|
||||
}
|
||||
|
||||
$('.small.modal').modal('show');
|
||||
})
|
||||
</script>
|
258
views/movies.tpl
Normal file
258
views/movies.tpl
Normal file
|
@ -0,0 +1,258 @@
|
|||
<html>
|
||||
<head>
|
||||
<!DOCTYPE html>
|
||||
<script src="{{base_url}}static/jquery/jquery-latest.min.js"></script>
|
||||
<script src="{{base_url}}static/semantic/semantic.min.js"></script>
|
||||
<script src="{{base_url}}static/jquery/tablesort.js"></script>
|
||||
<link rel="stylesheet" href="{{base_url}}static/semantic/semantic.min.css">
|
||||
|
||||
<link rel="apple-touch-icon" sizes="120x120" href="{{base_url}}static/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="{{base_url}}static/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="{{base_url}}static/favicon-16x16.png">
|
||||
<link rel="manifest" href="{{base_url}}static/manifest.json">
|
||||
<link rel="mask-icon" href="{{base_url}}static/safari-pinned-tab.svg" color="#5bbad5">
|
||||
<link rel="shortcut icon" href="{{base_url}}static/favicon.ico">
|
||||
<meta name="msapplication-config" content="{{base_url}}static/browserconfig.xml">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
|
||||
<title>Movies - Bazarr</title>
|
||||
|
||||
<style>
|
||||
body {
|
||||
background-color: #272727;
|
||||
}
|
||||
#fondblanc {
|
||||
background-color: #ffffff;
|
||||
border-radius: 0px;
|
||||
box-shadow: 0px 0px 5px 5px #ffffff;
|
||||
margin-top: 32px;
|
||||
margin-bottom: 3em;
|
||||
padding: 2em 3em 2em 3em;
|
||||
}
|
||||
#tablemovies {
|
||||
padding-top: 1em;
|
||||
}
|
||||
#divdetails {
|
||||
min-height: 250px;
|
||||
}
|
||||
.fast.backward, .backward, .forward, .fast.forward {
|
||||
cursor: pointer;
|
||||
}
|
||||
.fast.backward, .backward, .forward, .fast.forward { pointer-events: auto; }
|
||||
.fast.backward.disabled, .backward.disabled, .forward.disabled, .fast.forward.disabled { pointer-events: none; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='loader' class="ui page dimmer">
|
||||
<div class="ui indeterminate text loader">Loading...</div>
|
||||
</div>
|
||||
% include('menu.tpl')
|
||||
|
||||
<div id="fondblanc" class="ui container">
|
||||
<div class="ui basic buttons">
|
||||
<button id="movieseditor" class="ui button"><i class="configure icon"></i>Movies Editor</button>
|
||||
</div>
|
||||
<table id="tablemovies" class="ui very basic selectable sortable table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="sorted ascending">Name</th>
|
||||
<th>Path</th>
|
||||
<th>Audio language</th>
|
||||
<th>Subtitles languages</th>
|
||||
<th>Hearing-impaired</th>
|
||||
<th class="no-sort"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
%import ast
|
||||
%import os
|
||||
%for row in rows:
|
||||
<tr class="selectable">
|
||||
<td><a href="{{base_url}}movie/{{row[5]}}">{{row[1]}}</a></td>
|
||||
<td>
|
||||
%if os.path.isfile(row[2]):
|
||||
<span data-tooltip="This path seems to be valid." data-inverted=""><i class="checkmark icon"></i></span>
|
||||
%else:
|
||||
<span data-tooltip="This path doesn't seems to be valid." data-inverted=""><i class="warning sign icon"></i></span>
|
||||
%end
|
||||
{{row[2]}}
|
||||
</td>
|
||||
<td>{{row[7]}}</td>
|
||||
<td>
|
||||
%subs_languages = ast.literal_eval(str(row[3]))
|
||||
%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[4] == None else row[4]}}</td>
|
||||
<td {{!"style='background-color: #e8e8e8;'" if row[4] == None else ""}}>
|
||||
<%
|
||||
subs_languages_list = []
|
||||
if subs_languages is not None:
|
||||
for subs_language in subs_languages:
|
||||
subs_languages_list.append(subs_language)
|
||||
end
|
||||
end
|
||||
%>
|
||||
<div class="config ui inverted basic compact icon" data-tooltip="Edit movies" data-inverted="" data-no="{{row[5]}}" 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>
|
||||
</tr>
|
||||
%end
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="ui grid">
|
||||
<div class="three column row">
|
||||
<div class="column"></div>
|
||||
<div class="center aligned column">
|
||||
<i class="\\
|
||||
%if page == "1":
|
||||
disabled\\
|
||||
%end
|
||||
fast backward icon"></i>
|
||||
<i class="\\
|
||||
%if page == "1":
|
||||
disabled\\
|
||||
%end
|
||||
backward icon"></i>
|
||||
{{page}} / {{max_page}}
|
||||
<i class="\\
|
||||
%if int(page) == int(max_page):
|
||||
disabled\\
|
||||
%end
|
||||
forward icon"></i>
|
||||
<i class="\\
|
||||
%if int(page) == int(max_page):
|
||||
disabled\\
|
||||
%end
|
||||
fast forward icon"></i>
|
||||
</div>
|
||||
<div class="right floated right aligned column">Total records: {{missing_count}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ui small modal">
|
||||
<i class="close icon"></i>
|
||||
<div class="header">
|
||||
<div id="movies_title"></div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<form name="movies_form" id="movies_form" action="" method="post" class="ui form">
|
||||
<div id="divdetails" class="ui grid">
|
||||
<div class="four wide column">
|
||||
<img id="movies_poster" class="ui image" src="">
|
||||
</div>
|
||||
<div class="twelve wide column">
|
||||
<div class="ui grid">
|
||||
<div class="middle aligned row">
|
||||
<div class="right aligned five wide column">
|
||||
<label>Audio language</label>
|
||||
</div>
|
||||
<div class="nine wide column">
|
||||
<div id="movies_audio_language"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="middle aligned row">
|
||||
<div class="right aligned five wide column">
|
||||
<label>Subtitles languages</label>
|
||||
</div>
|
||||
<div class="nine wide column">
|
||||
<select name="languages" id="movies_languages" {{!'multiple="" ' if single_language == 'False' else ''}}class="ui fluid selection dropdown">
|
||||
<option value="">Languages</option>
|
||||
%for language in languages:
|
||||
<option value="{{language[0]}}">{{language[1]}}</option>
|
||||
%end
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="middle aligned row">
|
||||
<div class="right aligned five wide column">
|
||||
<label>Hearing-impaired</label>
|
||||
</div>
|
||||
<div class="nine wide column">
|
||||
<div id="movies_hearing-impaired_div" class="ui toggle checkbox">
|
||||
<input name="hearing_impaired" id="movies_hearing-impaired" type="checkbox">
|
||||
<label></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="ui cancel button" >Cancel</button>
|
||||
<button type="submit" name="save" value="save" form="movies_form" class="ui blue approve button">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
% include('footer.tpl')
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
<script>
|
||||
if (sessionStorage.scrolly) {
|
||||
$(window).scrollTop(sessionStorage.scrolly);
|
||||
sessionStorage.clear();
|
||||
}
|
||||
|
||||
$('table').tablesort();
|
||||
|
||||
$('a, button:not(.cancel)').click(function(){
|
||||
$('#loader').addClass('active');
|
||||
})
|
||||
|
||||
$('.fast.backward').click(function(){
|
||||
location.href="?page=1";
|
||||
})
|
||||
$('.backward:not(.fast)').click(function(){
|
||||
location.href="?page={{int(page)-1}}";
|
||||
})
|
||||
$('.forward:not(.fast)').click(function(){
|
||||
location.href="?page={{int(page)+1}}";
|
||||
})
|
||||
$('.fast.forward').click(function(){
|
||||
location.href="?page={{int(max_page)}}";
|
||||
})
|
||||
|
||||
$('#movieseditor').click(function(){
|
||||
window.location = '{{base_url}}movieseditor';
|
||||
})
|
||||
|
||||
$('.modal')
|
||||
.modal({
|
||||
autofocus: false
|
||||
})
|
||||
;
|
||||
|
||||
$('.config').click(function(){
|
||||
sessionStorage.scrolly=$(window).scrollTop();
|
||||
|
||||
$('#movies_form').attr('action', '{{base_url}}edit_movies/' + $(this).data("no"));
|
||||
|
||||
$("#movies_title").html($(this).data("title"));
|
||||
$("#movies_poster").attr("src", "{{base_url}}image_proxy_movies" + $(this).data("poster"));
|
||||
|
||||
$("#movies_audio_language").html($(this).data("audio"));
|
||||
|
||||
$('#movies_languages').dropdown('clear');
|
||||
var languages_array = eval($(this).data("languages"));
|
||||
$('#movies_languages').dropdown('set selected',languages_array);
|
||||
|
||||
if ($(this).data("hearing-impaired") == "True") {
|
||||
$("#movies_hearing-impaired_div").checkbox('check');
|
||||
} else {
|
||||
$("#movies_hearing-impaired_div").checkbox('uncheck');
|
||||
}
|
||||
|
||||
$('.small.modal').modal('show');
|
||||
})
|
||||
|
||||
$('#movies_languages').dropdown();
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue