mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-24 17:56: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
|
||||
from utils import settings, dialog, language as lang, kodiSQL
|
||||
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:
|
||||
|
||||
conn = kodiSQL('emby')
|
||||
cursor = conn.cursor()
|
||||
emby_db = embydb.Embydb_Functions(cursor)
|
||||
item = emby_db.getItem_byKodiId(kodi_id, item_type)
|
||||
cursor.close()
|
||||
try:
|
||||
item_id = item[0]
|
||||
except TypeError:
|
||||
pass
|
||||
with DatabaseConn('emby') as conn:
|
||||
with closing(conn.cursor()) as cursor:
|
||||
emby_db = embydb.Embydb_Functions(cursor)
|
||||
item = emby_db.getItem_byKodiId(kodi_id, item_type)
|
||||
try:
|
||||
item_id = item[0]
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
return item_id
|
||||
|
||||
|
|
Loading…
Reference in a new issue