mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-24 09:46:11 +00:00
use the new DatabaseCon context class
use closing with for cursor
This commit is contained in:
parent
b3214a9250
commit
a58b644062
1 changed files with 10 additions and 9 deletions
|
@ -13,6 +13,8 @@ import embydb_functions as embydb
|
||||||
import musicutils as musicutils
|
import musicutils as musicutils
|
||||||
from utils import settings, dialog, language as lang, kodiSQL
|
from utils import settings, dialog, language as lang, kodiSQL
|
||||||
from dialogs import context
|
from dialogs import context
|
||||||
|
from database import DatabaseConn
|
||||||
|
from contextlib import closing
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
@ -87,15 +89,14 @@ class ContextMenu(object):
|
||||||
|
|
||||||
if not item_id and kodi_id and item_type:
|
if not item_id and kodi_id and item_type:
|
||||||
|
|
||||||
conn = kodiSQL('emby')
|
with DatabaseConn('emby') as conn:
|
||||||
cursor = conn.cursor()
|
with closing(conn.cursor()) as cursor:
|
||||||
emby_db = embydb.Embydb_Functions(cursor)
|
emby_db = embydb.Embydb_Functions(cursor)
|
||||||
item = emby_db.getItem_byKodiId(kodi_id, item_type)
|
item = emby_db.getItem_byKodiId(kodi_id, item_type)
|
||||||
cursor.close()
|
try:
|
||||||
try:
|
item_id = item[0]
|
||||||
item_id = item[0]
|
except TypeError:
|
||||||
except TypeError:
|
pass
|
||||||
pass
|
|
||||||
|
|
||||||
return item_id
|
return item_id
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue