Merge remote-tracking branch 'origin/development' into halali

pull/489/head
Halali 6 years ago
commit 3c2958ffd3

@ -13,6 +13,8 @@ def get_args():
config_dir = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'data')) config_dir = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'data'))
parser.add_argument('-c', '--config', default=config_dir, type=str, metavar="DIR", parser.add_argument('-c', '--config', default=config_dir, type=str, metavar="DIR",
dest="config_dir", help="Directory containing the configuration (default: %s)" % config_dir) dest="config_dir", help="Directory containing the configuration (default: %s)" % config_dir)
parser.add_argument('-p', '--port', type=int, metavar="PORT", dest="port",
help="Port number (default: 6767)")
parser.add_argument('--no-update', default=False, type=bool, const=True, metavar="BOOL", nargs="?", parser.add_argument('--no-update', default=False, type=bool, const=True, metavar="BOOL", nargs="?",
help="Disable update functionality (default: False)") help="Disable update functionality (default: False)")
parser.add_argument('--debug', default=False, type=bool, const=True, metavar="BOOL", nargs="?", parser.add_argument('--debug', default=False, type=bool, const=True, metavar="BOOL", nargs="?",

@ -83,11 +83,19 @@ def sync_episodes():
format = episode['episodeFile']['quality']['quality']['name'] format = episode['episodeFile']['quality']['quality']['name']
resolution = str(episode['episodeFile']['quality']['quality']['resolution']) + 'p' resolution = str(episode['episodeFile']['quality']['quality']['resolution']) + 'p'
videoCodec = episode['episodeFile']['mediaInfo']['videoCodec'] if 'mediaInfo' in episode['episodeFile']:
videoCodec = SonarrFormatVideoCodec(videoCodec) if 'videoCodec' in episode['episodeFile']['mediaInfo']:
videoCodec = episode['episodeFile']['mediaInfo']['videoCodec']
audioCodec = episode['episodeFile']['mediaInfo']['audioCodec'] videoCodec = SonarrFormatVideoCodec(videoCodec)
audioCodec = SonarrFormatAudioCodec(audioCodec) else: videoCodec = None
if 'audioCodec' in episode['episodeFile']['mediaInfo']:
audioCodec = episode['episodeFile']['mediaInfo']['audioCodec']
audioCodec = SonarrFormatAudioCodec(audioCodec)
else: audioCodec = None
else:
videoCodec = None
audioCodec = None
# Add episodes in sonarr to current episode list # Add episodes in sonarr to current episode list
current_episodes_sonarr.append(episode['id']) current_episodes_sonarr.append(episode['id'])

@ -86,17 +86,23 @@ def update_movies():
format = movie['movieFile']['quality']['quality']['name'] format = movie['movieFile']['quality']['quality']['name']
resolution = movie['movieFile']['quality']['quality']['resolution'].lstrip('r').lower() resolution = movie['movieFile']['quality']['quality']['resolution'].lstrip('r').lower()
videoFormat = movie['movieFile']['mediaInfo']['videoFormat'] if 'mediaInfo' in movie['movieFile']:
videoCodecID = movie['movieFile']['mediaInfo']['videoCodecID'] videoFormat = videoCodecID = videoProfile = videoCodecLibrary = None
videoProfile = movie['movieFile']['mediaInfo']['videoProfile'] if 'videoFormat' in movie['movieFile']['mediaInfo']: videoFormat = movie['movieFile']['mediaInfo']['videoFormat']
videoCodecLibrary = movie['movieFile']['mediaInfo']['videoCodecLibrary'] if 'videoCodecID' in movie['movieFile']['mediaInfo']: videoCodecID = movie['movieFile']['mediaInfo']['videoCodecID']
videoCodec = RadarrFormatVideoCodec(videoFormat, videoCodecID, videoProfile, videoCodecLibrary) if 'videoProfile' in movie['movieFile']['mediaInfo']: videoProfile = movie['movieFile']['mediaInfo']['videoProfile']
if 'videoCodecLibrary' in movie['movieFile']['mediaInfo']: videoCodecLibrary = movie['movieFile']['mediaInfo']['videoCodecLibrary']
audioFormat = movie['movieFile']['mediaInfo']['audioFormat'] videoCodec = RadarrFormatVideoCodec(videoFormat, videoCodecID, videoProfile, videoCodecLibrary)
audioCodecID = movie['movieFile']['mediaInfo']['audioCodecID']
audioProfile = movie['movieFile']['mediaInfo']['audioProfile'] audioFormat = audioCodecID = audioProfile = audioAdditionalFeatures = None
audioAdditionalFeatures = movie['movieFile']['mediaInfo']['audioAdditionalFeatures'] if 'audioFormat' in movie['movieFile']['mediaInfo']: audioFormat = movie['movieFile']['mediaInfo']['audioFormat']
audioCodec = RadarrFormatAudioCodec(audioFormat, audioCodecID, audioProfile, audioAdditionalFeatures) if 'audioCodecID' in movie['movieFile']['mediaInfo']: audioCodecID = movie['movieFile']['mediaInfo']['audioCodecID']
if 'audioProfile' in movie['movieFile']['mediaInfo']: audioProfile = movie['movieFile']['mediaInfo']['audioProfile']
if 'audioAdditionalFeatures' in movie['movieFile']['mediaInfo']: audioAdditionalFeatures = movie['movieFile']['mediaInfo']['audioAdditionalFeatures']
audioCodec = RadarrFormatAudioCodec(audioFormat, audioCodecID, audioProfile, audioAdditionalFeatures)
else:
videoCodec = None
audioCodec = None
# Add movies in radarr to current movies list # Add movies in radarr to current movies list
current_movies_radarr.append(unicode(movie['tmdbId'])) current_movies_radarr.append(unicode(movie['tmdbId']))

@ -297,8 +297,8 @@ def manual_search(path, language, hi, providers, providers_auth, sceneName, titl
score = compute_score(matches, s, video, hearing_impaired=hi) score = compute_score(matches, s, video, hearing_impaired=hi)
not_matched = scores - matches not_matched = scores - matches
s.score = score s.score = score
if score < min_score: # if score < min_score:
continue # continue
subtitles_list.append( subtitles_list.append(
dict(score=round((score / max_score * 100), 2), dict(score=round((score / max_score * 100), 2),

@ -98,7 +98,7 @@ if cfg.has_section('general'):
# Move providers settings from DB to config file # Move providers settings from DB to config file
try: try:
db = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30) db = sqlite3.connect(os.path.join(args.config_dir, 'db', 'bazarr.db'), timeout=30)
c = db.cursor() c = db.cursor()
enabled_providers = c.execute("SELECT * FROM table_settings_providers WHERE enabled = 1").fetchall() enabled_providers = c.execute("SELECT * FROM table_settings_providers WHERE enabled = 1").fetchall()
settings_providers = c.execute("SELECT * FROM table_settings_providers").fetchall() settings_providers = c.execute("SELECT * FROM table_settings_providers").fetchall()
@ -125,7 +125,7 @@ try:
settings.legendastv.password = provider[3] settings.legendastv.password = provider[3]
settings.general.enabled_providers = u'' if not providers_list else ','.join(providers_list) settings.general.enabled_providers = u'' if not providers_list else ','.join(providers_list)
with open(os.path.join(config_dir, 'config', 'config.ini'), 'w+') as handle: with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle:
settings.write(handle) settings.write(handle)
except: except:

@ -2,7 +2,23 @@
bazarr_version = '0.7.2' bazarr_version = '0.7.2'
from gevent import monkey # Try to import gevent and exit if it's not available. This one is required to use websocket.
try:
from gevent import monkey
except ImportError:
import logging
logging.exception('BAZARR require gevent Python module to be installed using pip.')
try:
import os
from get_args import args
stop_file = open(os.path.join(args.config_dir, "bazarr.stop"), "w")
except Exception as e:
logging.error('BAZARR Cannot create bazarr.stop file.')
else:
stop_file.write('')
stop_file.close()
os._exit(0)
monkey.patch_all() monkey.patch_all()
import gc import gc
@ -26,10 +42,10 @@ from init import *
from update_db import * from update_db import *
from notifier import update_notifier from notifier import update_notifier
from logger import configure_logging, empty_log from logger import configure_logging, empty_log
import gevent
from gevent.pywsgi import WSGIServer from gevent.pywsgi import WSGIServer
from geventwebsocket import WebSocketError from geventwebsocket import WebSocketError
from geventwebsocket.handler import WebSocketHandler from geventwebsocket.handler import WebSocketHandler
# from cherrypy.wsgiserver import CherryPyWSGIServer
from io import BytesIO from io import BytesIO
from six import text_type from six import text_type
from beaker.middleware import SessionMiddleware from beaker.middleware import SessionMiddleware
@ -80,20 +96,6 @@ if "PYCHARM_HOSTED" in os.environ:
else: else:
bottle.ERROR_PAGE_TEMPLATE = bottle.ERROR_PAGE_TEMPLATE.replace('if DEBUG and', 'if') bottle.ERROR_PAGE_TEMPLATE = bottle.ERROR_PAGE_TEMPLATE.replace('if DEBUG and', 'if')
# Install gevent under user directory if it'S not already available. This one is required to use websocket.
try:
import gevent
except ImportError as e:
logging.exception('BAZARR require gevent Python module to be installed using pip.')
try:
stop_file = open(os.path.join(args.config_dir, "bazarr.stop"), "w")
except Exception as e:
logging.error('BAZARR Cannot create bazarr.stop file.')
else:
stop_file.write('')
stop_file.close()
os._exit(0)
# Reset restart required warning on start # Reset restart required warning on start
conn = sqlite3.connect(os.path.join(args.config_dir, 'db', 'bazarr.db'), timeout=30) conn = sqlite3.connect(os.path.join(args.config_dir, 'db', 'bazarr.db'), timeout=30)
c = conn.cursor() c = conn.cursor()
@ -1911,12 +1913,10 @@ def handle_websocket():
# Mute DeprecationWarning # Mute DeprecationWarning
warnings.simplefilter("ignore", DeprecationWarning) warnings.simplefilter("ignore", DeprecationWarning)
server = WSGIServer((str(settings.general.ip), (int(args.port) if args.port else int(settings.general.port))), app, handler_class=WebSocketHandler)
server = WSGIServer((str(settings.general.ip), int(settings.general.port)), app, handler_class=WebSocketHandler)
try: try:
logging.info('BAZARR is started and waiting for request on http://' + str(settings.general.ip) + ':' + str( logging.info('BAZARR is started and waiting for request on http://' + str(settings.general.ip) + ':' + (str(
settings.general.port) + str(base_url)) args.port) if args.port else str(settings.general.port)) + str(base_url))
# print 'Bazarr is started and waiting for request on http://' + str(ip) + ':' + str(port) + str(base_url)
server.serve_forever() server.serve_forever()
except KeyboardInterrupt: except KeyboardInterrupt:
shutdown() shutdown()

@ -192,8 +192,9 @@
}); });
% from config import settings % from config import settings
% from get_args import args
% ip = settings.general.ip % ip = settings.general.ip
% port = settings.general.port % port = args.port if args.port else settings.general.port
% base_url = settings.general.base_url % base_url = settings.general.base_url
if ("{{ip}}" === "0.0.0.0") { if ("{{ip}}" === "0.0.0.0") {

@ -385,8 +385,9 @@
}); });
% from config import settings % from config import settings
% from get_args import args
% ip = settings.general.ip % ip = settings.general.ip
% port = settings.general.port % port = args.port if args.port else settings.general.port
% base_url = settings.general.base_url % base_url = settings.general.base_url
if ("{{ip}}" === "0.0.0.0") { if ("{{ip}}" === "0.0.0.0") {

Loading…
Cancel
Save