Skip to content

Commit

Permalink
Merge branch 'master' into fix_for_#350
Browse files Browse the repository at this point in the history
  • Loading branch information
mammo0 committed Nov 2, 2020
2 parents 5522c93 + 75469b1 commit dd7bca7
Show file tree
Hide file tree
Showing 11 changed files with 1,054 additions and 109 deletions.
61 changes: 19 additions & 42 deletions jellyfin_kodi/database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ class Database(object):
discovered = False
discovered_file = None

def __init__(self, file=None, commit_close=True):
def __init__(self, db_file=None, commit_close=True):

''' file: jellyfin, texture, music, video, :memory: or path to file
'''
self.db_file = file or "video"
self.db_file = db_file or "video"
self.commit_close = commit_close

def __enter__(self):
Expand Down Expand Up @@ -112,69 +112,46 @@ def _discover_database(self, database):
}
database = types[database]
dirs, files = xbmcvfs.listdir(databases)
modified = {'file': None, 'time': 0}
modified = {'db_file': None, 'time': 0}

for file in reversed(files):
for db_file in reversed(files):

if (file.startswith(database) and not file.endswith('-wal') and not file.endswith('-shm') and not file.endswith('db-journal')):
if (db_file.startswith(database) and not db_file.endswith('-wal') and not db_file.endswith('-shm') and not db_file.endswith('db-journal')):

st = xbmcvfs.Stat(databases + file)
st = xbmcvfs.Stat(databases + db_file)
modified_int = st.st_mtime()
LOG.debug("Database detected: %s time: %s", file, modified_int)
LOG.debug("Database detected: %s time: %s", db_file, modified_int)

if modified_int > modified['time']:

modified['time'] = modified_int
modified['file'] = file
modified['db_file'] = db_file

LOG.debug("Discovered database: %s", modified)
self.discovered_file = modified['file']
self.discovered_file = modified['db_file']

return xbmc.translatePath("special://database/%s" % modified['file'])
return xbmc.translatePath("special://database/%s" % modified['db_file'])

def _sql(self, file):
def _sql(self, db_file):

''' Get the database path based on the file objects/obj_map.json
Compatible check, in the event multiple db version are supported with the same Kodi version.
Discover by file as a last resort.
'''
databases = obj.Objects().objects

if file not in ('video', 'music', 'texture') or databases.get('database_set%s' % file):
return self._get_database(databases[file], True)
if db_file not in ('video', 'music', 'texture') or databases.get('database_set%s' % db_file):
return self._get_database(databases[db_file], True)

discovered = self._discover_database(file) if not databases.get('database_set%s' % file) else None
discovered = self._discover_database(db_file) if not databases.get('database_set%s' % db_file) else None

try:
loaded = self._get_database(databases[file]) if file in databases else file
except Exception as error:
LOG.exception(error)

for i in range(1, 10):
alt_file = "%s-%s" % (file, i)

try:
loaded = self._get_database(databases[alt_file])

break
except KeyError: # No other db options
loaded = None

break
except Exception as error:
LOG.exception(error)

if discovered and discovered != loaded:

databases[file] = discovered
self.discovered = True
else:
databases[file] = loaded
databases[db_file] = discovered
self.discovered = True

databases['database_set%s' % file] = True
LOG.info("Database locked in: %s", databases[file])
databases['database_set%s' % db_file] = True
LOG.info("Database locked in: %s", databases[db_file])

return databases[file]
return databases[db_file]

def __exit__(self, exc_type, exc_val, exc_tb):

Expand Down
13 changes: 7 additions & 6 deletions jellyfin_kodi/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#################################################################################################

LOG = LazyLogger(__name__)
LIMIT = min(int(settings('limitIndex') or 50), 50)
DTHREADS = int(settings('limitThreads') or 3)

#################################################################################################

Expand Down Expand Up @@ -246,6 +244,9 @@ def _get_items(query, server_id=None):
'RestorePoint': {}
}

limit = min(int(settings('limitIndex') or 50), 50)
dthreads = int(settings('limitThreads') or 3)

url = query['url']
query.setdefault('params', {})
params = query['params']
Expand All @@ -270,21 +271,21 @@ def get_query_params(params, start, count):
return params_copy

query_params = [
get_query_params(params, offset, LIMIT)
get_query_params(params, offset, limit)
for offset
in range(params['StartIndex'], items['TotalRecordCount'], LIMIT)
in range(params['StartIndex'], items['TotalRecordCount'], limit)
]

# multiprocessing.dummy.Pool completes all requests in multiple threads but has to
# complete all tasks before allowing any results to be processed. ThreadPoolExecutor
# allows for completed tasks to be processed while other tasks are completed on other
# threads. Dont be a dummy.Pool, be a ThreadPoolExecutor
with concurrent.futures.ThreadPoolExecutor(DTHREADS) as p:
with concurrent.futures.ThreadPoolExecutor(dthreads) as p:
# dictionary for storing the jobs and their results
jobs = {}

# semaphore to avoid fetching complete library to memory
thread_buffer = threading.Semaphore(DTHREADS)
thread_buffer = threading.Semaphore(dthreads)

# wrapper function for _get that uses a semaphore
def get_wrapper(params):
Expand Down
17 changes: 10 additions & 7 deletions release.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
version: '0.6.2'
version: '0.6.3'
changelog: |
- #373 Use correct filename for kodirepo command
- #382 Handle empty XMLs in profile video
- #384 Add BDMV and DVD Rip support in TV Shows
- #385 Normalize path for os.mkdir
- #387 Optimize music sync for large libraries
- #392 Fix the pipeline. Again.
- #395 Add more transcoding options
- #398 Fix removed log level in Kodi 19
- #399 Fix extracted subtitle delivery for transcodes
- #401 Add an option to reduce max artwork resolution
- #403 Fix flake8 lints
- #406 Add linting to azure pipeline
- #408 Improve validation pipeline
- #412 Fix db error messages on startup
- #413 Fix need for restart/reboot for sync settings changes to take effect
8 changes: 6 additions & 2 deletions resources/language/resource.language.es_419/strings.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"PO-Revision-Date: 2020-10-09 21:47+0000\n"
"Last-Translator: Page Asgardius <hackerman@disroot.org>\n"
"PO-Revision-Date: 2020-10-15 00:33+0000\n"
"Last-Translator: wbrmdz <wbermudez@gmail.com>\n"
"Language-Team: Spanish (Latin America) <https://translate.jellyfin.org/"
"projects/jellyfin/jellyfin-kodi/es_419/>\n"
"Language: es_419\n"
Expand Down Expand Up @@ -997,3 +997,7 @@ msgstr "Codec de video preferido"
msgctxt "#30160"
msgid "Max stream bitrate"
msgstr "Tasa de bits máxima"

msgctxt "#30165"
msgid "Allow burned subtitles"
msgstr "Permitir subtítulos permanentes"
88 changes: 86 additions & 2 deletions resources/language/resource.language.es_AR/strings.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"PO-Revision-Date: 2020-10-04 18:37+0000\n"
"Last-Translator: Page Asgardius <hackerman@disroot.org>\n"
"PO-Revision-Date: 2020-10-19 18:22+0000\n"
"Last-Translator: Franco Castillo <castillofrancodamian@gmail.com>\n"
"Language-Team: Spanish (Argentina) <https://translate.jellyfin.org/projects/"
"jellyfin/jellyfin-kodi/es_AR/>\n"
"Language: es_AR\n"
Expand Down Expand Up @@ -913,3 +913,87 @@ msgid "Find more info in the github wiki/Create-and-restore-from-backup."
msgstr ""
"Encuentra más información en el wiki de GitHub dentro de la sección \"Crear "
"y restaurar desde copia de seguridad\"."

msgctxt "#33201"
msgid "Max artwork resolution"
msgstr "Resolución máxima de ilustraciones"

msgctxt "#33195"
msgid "Enable Jellyfin for Kodi"
msgstr "Habilitar Jellyfin para Kodi"

msgctxt "#33186"
msgid "The Kodi Sync Queue speeds up the start up sync. Other syncs are triggered by server events."
msgstr ""
"La Cola de sincronización de Kodi acelera la sincronización de inicio. Otras "
"sincronizaciones se activan mediante eventos del servidor."

msgctxt "#33183"
msgid "Enable the option to play with cinema mode"
msgstr "Habilitar la opción de reproducir con el modo cine"

msgctxt "#33181"
msgid "Restarting to apply the patch"
msgstr "Reiniciando para aplicar el parche"

msgctxt "#33175"
msgid "Paging tip: Each download thread requests your max items value from Jellyfin at the same time."
msgstr ""
"Sugerencia de paginación: cada hilo de descarga solicita el valor máximo de "
"artículos de Jellyfin al mismo tiempo."

msgctxt "#33174"
msgid "Paging - download threads (default: 3)"
msgstr "Paginación - hilos de descarga (predeterminado: 3)"

msgctxt "#33171"
msgid "By first letter"
msgstr "Por primera letra"

msgctxt "#33153"
msgid "Your Jellyfin theme media has been synced to Kodi"
msgstr "Los medios de tu tema de Jellyfin se han sincronizado con Kodi"

msgctxt "#33131"
msgid "Refreshing boxsets"
msgstr "Actualizando caja recopilatoria"

msgctxt "#33115"
msgid "Transcode options"
msgstr "Opciones de transcodificación"

msgctxt "#33098"
msgid "Refresh boxsets"
msgstr "Actualizar caja recopilatoria"

msgctxt "#30524"
msgid "Transcode VC-1"
msgstr "Transcodificar VC-1"

msgctxt "#30523"
msgid "Transcode MPEG2"
msgstr "Transcodificar MPEG2"

msgctxt "#30165"
msgid "Allow burned subtitles"
msgstr "Permitir subtítulos quemados"

msgctxt "#30164"
msgid "Audio max channels"
msgstr "Máximo de canales de audio"

msgctxt "#30163"
msgid "Audio bitrate"
msgstr "Tasa de bits de audio"

msgctxt "#30162"
msgid "Preferred audio codec"
msgstr "Códec de audio preferido"

msgctxt "#30161"
msgid "Preferred video codec"
msgstr "Códec de video preferido"

msgctxt "#30160"
msgid "Max stream bitrate"
msgstr "Tasa de bits de transmisión máxima"
8 changes: 6 additions & 2 deletions resources/language/resource.language.es_es/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Jellyfin for Kodi\n"
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: 2020-10-09 21:47+0000\n"
"Last-Translator: Page Asgardius <hackerman@disroot.org>\n"
"PO-Revision-Date: 2020-10-14 23:11+0000\n"
"Last-Translator: wbrmdz <wbermudez@gmail.com>\n"
"Language-Team: Spanish <https://translate.jellyfin.org/projects/jellyfin/"
"jellyfin-kodi/es/>\n"
"Language: es_es\n"
Expand Down Expand Up @@ -1001,3 +1001,7 @@ msgstr "Codec de video preferido"
msgctxt "#30160"
msgid "Max stream bitrate"
msgstr "Tasa de bits máxima"

msgctxt "#30165"
msgid "Allow burned subtitles"
msgstr "Permitir subtítulos permanentes"
24 changes: 22 additions & 2 deletions resources/language/resource.language.hu_hu/strings.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"PO-Revision-Date: 2020-06-08 08:48+0000\n"
"Last-Translator: Adam Bokor <bokoradam112@gmail.com>\n"
"PO-Revision-Date: 2020-10-20 08:26+0000\n"
"Last-Translator: Ákos Papp <pakosbotond@gmail.com>\n"
"Language-Team: Hungarian <https://translate.jellyfin.org/projects/jellyfin/"
"jellyfin-kodi/hu/>\n"
"Language: hu_hu\n"
Expand Down Expand Up @@ -955,3 +955,23 @@ msgstr "Kedvenc műsorok"
msgctxt "#33161"
msgid "Update password"
msgstr "Jelszó frissítése"

#, fuzzy
msgctxt "#33115"
msgid "Transcode options"
msgstr "Átkódolási lehetőségek"

#, fuzzy
msgctxt "#30165"
msgid "Allow burned subtitles"
msgstr "Égetett feliratok engedélyezése"

#, fuzzy
msgctxt "#30162"
msgid "Preferred audio codec"
msgstr "Előnyben részesített audiókodek"

#, fuzzy
msgctxt "#30161"
msgid "Preferred video codec"
msgstr "Előnyben részesített videokodek"

0 comments on commit dd7bca7

Please sign in to comment.