PlexKodiConnect/resources/lib/plex_db/__init__.py

30 lines
806 B
Python
Raw Normal View History

2018-10-22 01:56:13 +11:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, unicode_literals
from .common import PlexDBBase, initialize, wipe, PLEXDB_LOCK
2018-10-23 22:54:09 +11:00
from .tvshows import TVShows
from .movies import Movies
2018-10-25 00:20:25 +11:00
from .music import Music
2018-10-25 02:17:02 +11:00
from .playlists import Playlists
2018-10-26 01:07:34 +11:00
from .sections import Sections
2018-10-22 01:56:13 +11:00
2018-10-26 01:07:34 +11:00
class PlexDB(PlexDBBase, TVShows, Movies, Music, Playlists, Sections):
2018-10-23 22:54:09 +11:00
pass
2019-03-26 03:15:18 +11:00
def kodi_from_plex(plex_id, plex_type=None):
"""
Returns the tuple (kodi_id, kodi_type) for plex_id. Faster, if plex_type
is provided
Returns (None, None) if unsuccessful
"""
with PlexDB(lock=False) as plexdb:
db_item = plexdb.item_by_id(plex_id, plex_type)
if db_item:
return (db_item['kodi_id'], db_item['kodi_type'])
else:
return None, None