Merge branch 'development' into python3

# Conflicts:
#	bazarr/analytics.py
#	bazarr/get_series.py
pull/684/head
Louis Vézina 5 years ago
commit 43d33dc247

@ -28,11 +28,13 @@ def track_event(category=None, action=None, label=None):
tracker = Tracker('UA-138214134-3', 'none', conf=anonymousConfig)
try:
visitor = pickle.loads(base64.b64decode(settings.analytics.visitor))
if settings.analytics.visitor:
visitor = pickle.loads(base64.b64decode(settings.analytics.visitor))
if visitor.unique_id > int(0x7fffffff):
visitor.unique_id = random.randint(0, 0x7fffffff)
except:
visitor = Visitor()
unique_id = int(random.getrandbits(32))
visitor.unique_id = unique_id
visitor.unique_id = long(random.randint(0, 0x7fffffff))
session = Session()
event = Event(category=category, action=action, label=label, value=1)

@ -9,9 +9,9 @@ from playhouse.sqliteq import SqliteQueueDatabase
from helper import path_replace, path_replace_movie, path_replace_reverse, path_replace_reverse_movie
database = SqliteQueueDatabase(
os.path.join(args.config_dir, 'db', 'bazarr.db'),
None,
use_gevent=False,
autostart=True,
autostart=False,
queue_max_size=256, # Max. # of pending writes that can accumulate.
results_timeout=30.0) # Max. time to wait for query to be executed.
@ -169,6 +169,8 @@ class TableSettingsNotifier(BaseModel):
def database_init():
database.init(os.path.join(args.config_dir, 'db', 'bazarr.db'))
database.start()
database.connect()
database.pragma('wal_checkpoint', 'TRUNCATE') # Run a checkpoint and merge remaining wal-journal.
@ -181,22 +183,7 @@ def database_init():
database.create_tables(models_list, safe=True)
# Insert default values
if System.select().count() == 0:
System.insert(
{
System.updated: 0,
System.configured: 0
}
).execute()
def wal_cleaning():
database.pragma('wal_checkpoint', 'TRUNCATE') # Run a checkpoint and merge remaining wal-journal.
database.wal_autocheckpoint = 50 # Run an automatic checkpoint every 50 write transactions.
@atexit.register
def _stop_worker_threads():
database.close()
database.stop()

@ -28,7 +28,7 @@ class EmbeddedSubsReader:
detected_languages = []
for detected_language in data['subtitles']:
subtitles_list.append([detected_language['language'], detected_language['forced']])
subtitles_list.append([detected_language['language'], detected_language['forced'], detected_language["codec"]])
else:
if os.path.splitext(file)[1] == '.mkv':
with open(file, 'rb') as f:

@ -20,6 +20,7 @@ import six
def update_series():
notifications.write(msg="Update series list from Sonarr is running...", queue='get_series')
apikey_sonarr = settings.sonarr.apikey
sonarr_version = get_sonarr_version()
serie_default_enabled = settings.general.getboolean('serie_default_enabled')
serie_default_language = settings.general.serie_default_language
serie_default_hi = settings.general.serie_default_hi
@ -107,7 +108,7 @@ def update_series():
'overview': overview,
'poster': poster,
'fanart': fanart,
'audio_language': profile_id_to_language((show['qualityProfileId'] if get_sonarr_version().startswith('2') else show['languageProfileId']), audio_profiles),
'audio_language': profile_id_to_language((show['qualityProfileId'] if sonarr_version.startswith('2') else show['languageProfileId']), audio_profiles),
'sort_title': show['sortTitle'],
'year': show['year'],
'alternate_titles': alternateTitles,
@ -120,7 +121,7 @@ def update_series():
'overview': overview,
'poster': poster,
'fanart': fanart,
'audio_language': profile_id_to_language((show['qualityProfileId'] if get_sonarr_version().startswith('2') else show['languageProfileId']), audio_profiles),
'audio_language': profile_id_to_language((show['qualityProfileId'] if sonarr_version.startswith('2') else show['languageProfileId']), audio_profiles),
'sort_title': show['sortTitle'],
'year': show['year'],
'alternate_title': alternateTitles})

@ -78,7 +78,7 @@ def get_video(path, title, sceneName, use_scenename, providers=None, media_type=
logging.debug('BAZARR is using those video object properties: %s', vars(video))
return video
except:
except Exception as e:
logging.exception("BAZARR Error trying to get video information for this file: " + path)

@ -69,6 +69,23 @@ config_file = os.path.normpath(os.path.join(args.config_dir, 'config', 'config.i
cfg = configparser2.ConfigParser()
if not os.path.exists(os.path.normpath(os.path.join(args.config_dir, 'config', 'users.json'))):
cork = Cork(os.path.normpath(os.path.join(args.config_dir, 'config')), initialize=True)
cork._store.roles[''] = 100
cork._store.save_roles()
tstamp = str(time.time())
username = password = ''
cork._store.users[username] = {
'role': '',
'hash': cork._hash(username, password),
'email_addr': username,
'desc': username,
'creation_date': tstamp
}
cork._store.save_users()
def init_binaries():
exe = get_binary("unrar")

@ -38,8 +38,12 @@ def store_subtitles(file):
logging.debug("BAZARR is trying to index embedded subtitles.")
try:
subtitle_languages = embedded_subs_reader.list_languages(file)
for subtitle_language, subtitle_forced in subtitle_languages:
for subtitle_language, subtitle_forced, subtitle_codec in subtitle_languages:
try:
if settings.general.getboolean("ignore_pgs_subs") and subtitle_codec == "hdmv_pgs_subtitle":
logging.debug("BAZARR skipping pgs sub for language: " + str(alpha2_from_alpha3(subtitle_language)))
continue
if alpha2_from_alpha3(subtitle_language) is not None:
lang = str(alpha2_from_alpha3(subtitle_language))
if subtitle_forced:
@ -130,8 +134,12 @@ def store_subtitles_movie(file):
logging.debug("BAZARR is trying to index embedded subtitles.")
try:
subtitle_languages = embedded_subs_reader.list_languages(file)
for subtitle_language, subtitle_forced in subtitle_languages:
for subtitle_language, subtitle_forced, subtitle_codec in subtitle_languages:
try:
if settings.general.getboolean("ignore_pgs_subs") and subtitle_codec == "hdmv_pgs_subtitle":
logging.debug("BAZARR skipping pgs sub for language: " + str(alpha2_from_alpha3(subtitle_language)))
continue
if alpha2_from_alpha3(subtitle_language) is not None:
lang = str(alpha2_from_alpha3(subtitle_language))
if subtitle_forced:

@ -91,10 +91,16 @@ else:
bottle.ERROR_PAGE_TEMPLATE = bottle.ERROR_PAGE_TEMPLATE.replace('if DEBUG and', 'if')
# Reset restart required warning on start
System.update({
System.configured: 0,
System.updated: 0
}).execute()
if System.select().count():
System.update({
System.configured: 0,
System.updated: 0
}).execute()
else:
System.insert({
System.configured: 0,
System.updated: 0
}).execute()
# Load languages in database
load_language_in_db()
@ -191,32 +197,29 @@ def shutdown():
except Exception as e:
logging.error('BAZARR Cannot create bazarr.stop file.')
else:
stop_file.write('')
stop_file.close()
server.stop()
database.close()
database.stop()
server.stop()
stop_file.write('')
stop_file.close()
sys.exit(0)
@route(base_url + 'restart')
def restart():
try:
server.stop()
except:
logging.error('BAZARR Cannot stop CherryPy.')
restart_file = open(os.path.join(args.config_dir, "bazarr.restart"), "w")
except Exception as e:
logging.error('BAZARR Cannot create bazarr.restart file.')
else:
try:
restart_file = open(os.path.join(args.config_dir, "bazarr.restart"), "w")
except Exception as e:
logging.error('BAZARR Cannot create bazarr.restart file.')
else:
# print 'Bazarr is being restarted...'
logging.info('Bazarr is being restarted...')
restart_file.write('')
restart_file.close()
database.close()
database.stop()
# print 'Bazarr is being restarted...'
logging.info('Bazarr is being restarted...')
server.stop()
database.close()
database.stop()
restart_file.write('')
restart_file.close()
sys.exit(0)
@route(base_url + 'wizard')
@ -442,7 +445,7 @@ def save_wizard():
settings_movie_default_hi = 'True'
settings.general.movie_default_hi = text_type(settings_movie_default_hi)
settings_movie_default_forced = str(request.forms.getall('settings_movie_default_forced'))
settings_movie_default_forced = str(request.forms.get('settings_movie_default_forced'))
settings.general.movie_default_forced = text_type(settings_movie_default_forced)
with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle:
@ -1124,7 +1127,13 @@ def history():
def historyseries():
authorize()
row_count = TableHistory.select().count()
row_count = TableHistory.select(
).join_from(
TableHistory, TableShows, JOIN.LEFT_OUTER
).where(
TableShows.title.is_null(False)
).count()
page = request.GET.page
if page == "":
page = "1"
@ -1168,6 +1177,8 @@ def historyseries():
TableHistory, TableShows, JOIN.LEFT_OUTER
).join_from(
TableHistory, TableEpisodes, JOIN.LEFT_OUTER
).where(
TableShows.title.is_null(False)
).order_by(
TableHistory.timestamp.desc()
).paginate(
@ -1229,7 +1240,13 @@ def historyseries():
def historymovies():
authorize()
row_count = TableHistoryMovie.select().count()
row_count = TableHistoryMovie.select(
).join_from(
TableHistoryMovie, TableMovies, JOIN.LEFT_OUTER
).where(
TableMovies.title.is_null(False)
).count()
page = request.GET.page
if page == "":
page = "1"
@ -1269,6 +1286,8 @@ def historymovies():
TableMovies.forced
).join_from(
TableHistoryMovie, TableMovies, JOIN.LEFT_OUTER
).where(
TableMovies.title.is_null(False)
).order_by(
TableHistoryMovie.timestamp.desc()
).paginate(

@ -9,7 +9,7 @@
<div class="five wide column">
<div class='field'>
<select name="settings_general_wanted_search_frequency" id="settings_general_wanted_search_frequency" class="ui fluid selection dropdown">
% for i in [1,3,6,12,24]:
% for i in [3,6,12,24]:
<option value="{{i}}">{{i}}</option>
%end
</select>

@ -105,9 +105,9 @@
<option value="">Languages</option>
%enabled_languages = []
%for language in settings_languages:
<option value="{{language[1]}}">{{language[2]}}</option>
%if language[3] == True:
% enabled_languages.append(str(language[1]))
<option value="{{language.code2}}">{{language.name}}</option>
%if language.enabled == True:
% enabled_languages.append(str(language.code2))
%end
%end
</select>

Loading…
Cancel
Save