Prettify
This commit is contained in:
parent
ca11528593
commit
5068327408
13 changed files with 489 additions and 530 deletions
File diff suppressed because it is too large
Load diff
|
@ -57,10 +57,10 @@ class PlexCompanion(Thread):
|
||||||
LOG.error('Could not download Plex metadata for: %s', data)
|
LOG.error('Could not download Plex metadata for: %s', data)
|
||||||
return
|
return
|
||||||
api = API(xml[0])
|
api = API(xml[0])
|
||||||
if api.getType() == v.PLEX_TYPE_ALBUM:
|
if api.plex_type() == v.PLEX_TYPE_ALBUM:
|
||||||
LOG.debug('Plex music album detected')
|
LOG.debug('Plex music album detected')
|
||||||
PQ.init_playqueue_from_plex_children(
|
PQ.init_playqueue_from_plex_children(
|
||||||
api.getRatingKey(),
|
api.plex_id(),
|
||||||
transient_token=data.get('token'))
|
transient_token=data.get('token'))
|
||||||
elif data['containerKey'].startswith('/playQueues/'):
|
elif data['containerKey'].startswith('/playQueues/'):
|
||||||
_, container_key, _ = ParseContainerKey(data['containerKey'])
|
_, container_key, _ = ParseContainerKey(data['containerKey'])
|
||||||
|
@ -70,7 +70,7 @@ class PlexCompanion(Thread):
|
||||||
dialog('notification', lang(29999), lang(30128), icon='{error}')
|
dialog('notification', lang(29999), lang(30128), icon='{error}')
|
||||||
return
|
return
|
||||||
playqueue = PQ.get_playqueue_from_type(
|
playqueue = PQ.get_playqueue_from_type(
|
||||||
v.KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE[api.getType()])
|
v.KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE[api.plex_type()])
|
||||||
playqueue.clear()
|
playqueue.clear()
|
||||||
get_playlist_details_from_xml(playqueue, xml)
|
get_playlist_details_from_xml(playqueue, xml)
|
||||||
playqueue.plex_transient_token = data.get('token')
|
playqueue.plex_transient_token = data.get('token')
|
||||||
|
@ -84,7 +84,7 @@ class PlexCompanion(Thread):
|
||||||
if data.get('offset') != '0':
|
if data.get('offset') != '0':
|
||||||
state.RESUMABLE = True
|
state.RESUMABLE = True
|
||||||
state.RESUME_PLAYBACK = True
|
state.RESUME_PLAYBACK = True
|
||||||
playback_triage(api.getRatingKey(), api.getType(), resolve=False)
|
playback_triage(api.plex_id(), api.plex_type(), resolve=False)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _process_node(data):
|
def _process_node(data):
|
||||||
|
@ -119,7 +119,7 @@ class PlexCompanion(Thread):
|
||||||
return
|
return
|
||||||
api = API(xml[0])
|
api = API(xml[0])
|
||||||
playqueue = PQ.get_playqueue_from_type(
|
playqueue = PQ.get_playqueue_from_type(
|
||||||
v.KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE[api.getType()])
|
v.KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE[api.plex_type()])
|
||||||
PQ.update_playqueue_from_PMS(
|
PQ.update_playqueue_from_PMS(
|
||||||
playqueue,
|
playqueue,
|
||||||
playqueue_id=container_key,
|
playqueue_id=container_key,
|
||||||
|
|
|
@ -100,7 +100,7 @@ class ContextMenu(object):
|
||||||
options.append(OPTIONS['PMS_Play'])
|
options.append(OPTIONS['PMS_Play'])
|
||||||
if self.kodi_type in v.KODI_VIDEOTYPES:
|
if self.kodi_type in v.KODI_VIDEOTYPES:
|
||||||
options.append(OPTIONS['Transcode'])
|
options.append(OPTIONS['Transcode'])
|
||||||
# userdata = self.api.getUserData()
|
# userdata = self.api.userdata()
|
||||||
# if userdata['Favorite']:
|
# if userdata['Favorite']:
|
||||||
# # Remove from emby favourites
|
# # Remove from emby favourites
|
||||||
# options.append(OPTIONS['RemoveFav'])
|
# options.append(OPTIONS['RemoveFav'])
|
||||||
|
|
|
@ -194,7 +194,7 @@ def GetSubFolders(nodeindex):
|
||||||
|
|
||||||
|
|
||||||
##### LISTITEM SETUP FOR VIDEONODES #####
|
##### LISTITEM SETUP FOR VIDEONODES #####
|
||||||
def createListItem(item, appendShowTitle=False, appendSxxExx=False):
|
def createListItem(item, append_show_title=False, append_sxxexx=False):
|
||||||
title = item['title']
|
title = item['title']
|
||||||
li = ListItem(title)
|
li = ListItem(title)
|
||||||
li.setProperty('IsPlayable', "true")
|
li.setProperty('IsPlayable', "true")
|
||||||
|
@ -215,7 +215,7 @@ def createListItem(item, appendShowTitle=False, appendSxxExx=False):
|
||||||
|
|
||||||
if season and episode:
|
if season and episode:
|
||||||
li.setProperty('episodeno', "s%.2de%.2d" % (season, episode))
|
li.setProperty('episodeno', "s%.2de%.2d" % (season, episode))
|
||||||
if appendSxxExx is True:
|
if append_sxxexx is True:
|
||||||
title = "S%.2dE%.2d - %s" % (season, episode, title)
|
title = "S%.2dE%.2d - %s" % (season, episode, title)
|
||||||
|
|
||||||
if "firstaired" in item:
|
if "firstaired" in item:
|
||||||
|
@ -223,7 +223,7 @@ def createListItem(item, appendShowTitle=False, appendSxxExx=False):
|
||||||
|
|
||||||
if "showtitle" in item:
|
if "showtitle" in item:
|
||||||
metadata['TVshowTitle'] = item['showtitle']
|
metadata['TVshowTitle'] = item['showtitle']
|
||||||
if appendShowTitle is True:
|
if append_show_title is True:
|
||||||
title = item['showtitle'] + ' - ' + title
|
title = item['showtitle'] + ' - ' + title
|
||||||
|
|
||||||
if "rating" in item:
|
if "rating" in item:
|
||||||
|
@ -375,8 +375,8 @@ def getRecentEpisodes(viewid, mediatype, tagname, limit):
|
||||||
# if the addon is called with recentepisodes parameter,
|
# if the addon is called with recentepisodes parameter,
|
||||||
# we return the recentepisodes list of the given tagname
|
# we return the recentepisodes list of the given tagname
|
||||||
xbmcplugin.setContent(HANDLE, 'episodes')
|
xbmcplugin.setContent(HANDLE, 'episodes')
|
||||||
appendShowTitle = settings('RecentTvAppendShow') == 'true'
|
append_show_title = settings('RecentTvAppendShow') == 'true'
|
||||||
appendSxxExx = settings('RecentTvAppendSeason') == 'true'
|
append_sxxexx = settings('RecentTvAppendSeason') == 'true'
|
||||||
# First we get a list of all the TV shows - filtered by tag
|
# First we get a list of all the TV shows - filtered by tag
|
||||||
allshowsIds = set()
|
allshowsIds = set()
|
||||||
params = {
|
params = {
|
||||||
|
@ -402,8 +402,8 @@ def getRecentEpisodes(viewid, mediatype, tagname, limit):
|
||||||
for episode in js.get_episodes(params):
|
for episode in js.get_episodes(params):
|
||||||
if episode['tvshowid'] in allshowsIds:
|
if episode['tvshowid'] in allshowsIds:
|
||||||
listitem = createListItem(episode,
|
listitem = createListItem(episode,
|
||||||
appendShowTitle=appendShowTitle,
|
append_show_title=append_show_title,
|
||||||
appendSxxExx=appendSxxExx)
|
append_sxxexx=append_sxxexx)
|
||||||
xbmcplugin.addDirectoryItem(
|
xbmcplugin.addDirectoryItem(
|
||||||
handle=HANDLE,
|
handle=HANDLE,
|
||||||
url=episode['file'],
|
url=episode['file'],
|
||||||
|
@ -501,7 +501,7 @@ def getExtraFanArt(plexid, plexPath):
|
||||||
return xbmcplugin.endOfDirectory(HANDLE)
|
return xbmcplugin.endOfDirectory(HANDLE)
|
||||||
|
|
||||||
api = API(xml[0])
|
api = API(xml[0])
|
||||||
backdrops = api.getAllArtwork()['Backdrop']
|
backdrops = api.artwork()['Backdrop']
|
||||||
for count, backdrop in enumerate(backdrops):
|
for count, backdrop in enumerate(backdrops):
|
||||||
# Same ordering as in artwork
|
# Same ordering as in artwork
|
||||||
fanartFile = try_encode(join(fanartDir, "fanart%.3d.jpg" % count))
|
fanartFile = try_encode(join(fanartDir, "fanart%.3d.jpg" % count))
|
||||||
|
@ -536,8 +536,8 @@ def getOnDeck(viewid, mediatype, tagname, limit):
|
||||||
limit: Max. number of items to retrieve, e.g. 50
|
limit: Max. number of items to retrieve, e.g. 50
|
||||||
"""
|
"""
|
||||||
xbmcplugin.setContent(HANDLE, 'episodes')
|
xbmcplugin.setContent(HANDLE, 'episodes')
|
||||||
appendShowTitle = settings('OnDeckTvAppendShow') == 'true'
|
append_show_title = settings('OnDeckTvAppendShow') == 'true'
|
||||||
appendSxxExx = settings('OnDeckTvAppendSeason') == 'true'
|
append_sxxexx = settings('OnDeckTvAppendSeason') == 'true'
|
||||||
directpaths = settings('useDirectPaths') == 'true'
|
directpaths = settings('useDirectPaths') == 'true'
|
||||||
if settings('OnDeckTVextended') == 'false':
|
if settings('OnDeckTVextended') == 'false':
|
||||||
# Chances are that this view is used on Kodi startup
|
# Chances are that this view is used on Kodi startup
|
||||||
|
@ -558,16 +558,16 @@ def getOnDeck(viewid, mediatype, tagname, limit):
|
||||||
limitcounter = 0
|
limitcounter = 0
|
||||||
for item in xml:
|
for item in xml:
|
||||||
api = API(item)
|
api = API(item)
|
||||||
listitem = api.CreateListItemFromPlexItem(
|
listitem = api.create_listitem(
|
||||||
appendShowTitle=appendShowTitle,
|
append_show_title=append_show_title,
|
||||||
appendSxxExx=appendSxxExx)
|
append_sxxexx=append_sxxexx)
|
||||||
if directpaths:
|
if directpaths:
|
||||||
url = api.getFilePath()
|
url = api.file_path()
|
||||||
else:
|
else:
|
||||||
params = {
|
params = {
|
||||||
'mode': "play",
|
'mode': "play",
|
||||||
'plex_id': api.getRatingKey(),
|
'plex_id': api.plex_id(),
|
||||||
'plex_type': api.getType()
|
'plex_type': api.plex_type()
|
||||||
}
|
}
|
||||||
url = "plugin://plugin.video.plexkodiconnect/tvshows/?%s" \
|
url = "plugin://plugin.video.plexkodiconnect/tvshows/?%s" \
|
||||||
% urlencode(params)
|
% urlencode(params)
|
||||||
|
@ -646,8 +646,8 @@ def getOnDeck(viewid, mediatype, tagname, limit):
|
||||||
for episode in episodes:
|
for episode in episodes:
|
||||||
# There will always be only 1 episode ('limit=1')
|
# There will always be only 1 episode ('limit=1')
|
||||||
listitem = createListItem(episode,
|
listitem = createListItem(episode,
|
||||||
appendShowTitle=appendShowTitle,
|
append_show_title=append_show_title,
|
||||||
appendSxxExx=appendSxxExx)
|
append_sxxexx=append_sxxexx)
|
||||||
xbmcplugin.addDirectoryItem(handle=HANDLE,
|
xbmcplugin.addDirectoryItem(handle=HANDLE,
|
||||||
url=episode['file'],
|
url=episode['file'],
|
||||||
listitem=listitem,
|
listitem=listitem,
|
||||||
|
@ -823,25 +823,25 @@ def __build_folder(xml_element, plex_section_id=None):
|
||||||
|
|
||||||
def __build_item(xml_element):
|
def __build_item(xml_element):
|
||||||
api = API(xml_element)
|
api = API(xml_element)
|
||||||
listitem = api.CreateListItemFromPlexItem()
|
listitem = api.create_listitem()
|
||||||
resume = api.getResume()
|
resume = api.resume_point()
|
||||||
if resume:
|
if resume:
|
||||||
listitem.setProperty('resumetime', str(resume))
|
listitem.setProperty('resumetime', str(resume))
|
||||||
if (api.getKey().startswith('/system/services') or
|
if (api.path_and_plex_id().startswith('/system/services') or
|
||||||
api.getKey().startswith('http')):
|
api.path_and_plex_id().startswith('http')):
|
||||||
params = {
|
params = {
|
||||||
'mode': 'plex_node',
|
'mode': 'plex_node',
|
||||||
'key': xml_element.attrib.get('key'),
|
'key': xml_element.attrib.get('key'),
|
||||||
'offset': xml_element.attrib.get('viewOffset', '0'),
|
'offset': xml_element.attrib.get('viewOffset', '0'),
|
||||||
}
|
}
|
||||||
url = "plugin://%s?%s" % (v.ADDON_ID, urlencode(params))
|
url = "plugin://%s?%s" % (v.ADDON_ID, urlencode(params))
|
||||||
elif api.getType() == v.PLEX_TYPE_PHOTO:
|
elif api.plex_type() == v.PLEX_TYPE_PHOTO:
|
||||||
url = api.get_picture_path()
|
url = api.get_picture_path()
|
||||||
else:
|
else:
|
||||||
params = {
|
params = {
|
||||||
'mode': 'play',
|
'mode': 'play',
|
||||||
'plex_id': api.getRatingKey(),
|
'plex_id': api.plex_id(),
|
||||||
'plex_type': api.getType(),
|
'plex_type': api.plex_type(),
|
||||||
}
|
}
|
||||||
url = "plugin://%s?%s" % (v.ADDON_ID, urlencode(params))
|
url = "plugin://%s?%s" % (v.ADDON_ID, urlencode(params))
|
||||||
xbmcplugin.addDirectoryItem(handle=HANDLE,
|
xbmcplugin.addDirectoryItem(handle=HANDLE,
|
||||||
|
|
|
@ -106,17 +106,17 @@ class Items(object):
|
||||||
return False
|
return False
|
||||||
api = API(xml[0])
|
api = API(xml[0])
|
||||||
if allartworks is None:
|
if allartworks is None:
|
||||||
allartworks = api.getAllArtwork()
|
allartworks = api.artwork()
|
||||||
self.artwork.addArtwork(api.getFanartArtwork(allartworks),
|
self.artwork.addArtwork(api.fanart_artwork(allartworks),
|
||||||
kodi_id,
|
kodi_id,
|
||||||
kodi_type,
|
kodi_type,
|
||||||
self.kodicursor)
|
self.kodicursor)
|
||||||
# Also get artwork for collections/movie sets
|
# Also get artwork for collections/movie sets
|
||||||
if kodi_type == v.KODI_TYPE_MOVIE:
|
if kodi_type == v.KODI_TYPE_MOVIE:
|
||||||
for setname in api.getCollections():
|
for setname in api.collection_list():
|
||||||
LOG.debug('Getting artwork for movie set %s', setname)
|
LOG.debug('Getting artwork for movie set %s', setname)
|
||||||
setid = self.kodi_db.createBoxset(setname)
|
setid = self.kodi_db.createBoxset(setname)
|
||||||
self.artwork.addArtwork(api.getSetArtwork(),
|
self.artwork.addArtwork(api.set_artwork(),
|
||||||
setid,
|
setid,
|
||||||
v.KODI_TYPE_SET,
|
v.KODI_TYPE_SET,
|
||||||
self.kodicursor)
|
self.kodicursor)
|
||||||
|
@ -133,13 +133,13 @@ class Items(object):
|
||||||
for mediaitem in xml:
|
for mediaitem in xml:
|
||||||
api = API(mediaitem)
|
api = API(mediaitem)
|
||||||
# Get key and db entry on the Kodi db side
|
# Get key and db entry on the Kodi db side
|
||||||
db_item = self.plex_db.getItem_byId(api.getRatingKey())
|
db_item = self.plex_db.getItem_byId(api.plex_id())
|
||||||
try:
|
try:
|
||||||
fileid = db_item[1]
|
fileid = db_item[1]
|
||||||
except TypeError:
|
except TypeError:
|
||||||
continue
|
continue
|
||||||
# Grab the user's viewcount, resume points etc. from PMS' answer
|
# Grab the user's viewcount, resume points etc. from PMS' answer
|
||||||
userdata = api.getUserData()
|
userdata = api.userdata()
|
||||||
# Write to Kodi DB
|
# Write to Kodi DB
|
||||||
self.kodi_db.addPlaystate(fileid,
|
self.kodi_db.addPlaystate(fileid,
|
||||||
userdata['Resume'],
|
userdata['Resume'],
|
||||||
|
@ -191,7 +191,7 @@ class Movies(Items):
|
||||||
# item update
|
# item update
|
||||||
# If the item doesn't exist, we'll add it to the database
|
# If the item doesn't exist, we'll add it to the database
|
||||||
update_item = True
|
update_item = True
|
||||||
itemid = api.getRatingKey()
|
itemid = api.plex_id()
|
||||||
# Cannot parse XML, abort
|
# Cannot parse XML, abort
|
||||||
if not itemid:
|
if not itemid:
|
||||||
LOG.error("Cannot parse XML data for movie")
|
LOG.error("Cannot parse XML data for movie")
|
||||||
|
@ -221,35 +221,35 @@ class Movies(Items):
|
||||||
movieid)
|
movieid)
|
||||||
|
|
||||||
# fileId information
|
# fileId information
|
||||||
checksum = api.getChecksum()
|
checksum = api.checksum()
|
||||||
dateadded = api.getDateCreated()
|
dateadded = api.date_created()
|
||||||
userdata = api.getUserData()
|
userdata = api.userdata()
|
||||||
playcount = userdata['PlayCount']
|
playcount = userdata['PlayCount']
|
||||||
dateplayed = userdata['LastPlayedDate']
|
dateplayed = userdata['LastPlayedDate']
|
||||||
resume = userdata['Resume']
|
resume = userdata['Resume']
|
||||||
runtime = userdata['Runtime']
|
runtime = userdata['Runtime']
|
||||||
|
|
||||||
# item details
|
# item details
|
||||||
people = api.getPeople()
|
people = api.people()
|
||||||
writer = api.joinList(people['Writer'])
|
writer = api.list_to_string(people['Writer'])
|
||||||
director = api.joinList(people['Director'])
|
director = api.list_to_string(people['Director'])
|
||||||
genres = api.getGenres()
|
genres = api.genre_list()
|
||||||
genre = api.joinList(genres)
|
genre = api.list_to_string(genres)
|
||||||
title, sorttitle = api.getTitle()
|
title, sorttitle = api.titles()
|
||||||
plot = api.getPlot()
|
plot = api.plot()
|
||||||
shortplot = None
|
shortplot = None
|
||||||
tagline = api.getTagline()
|
tagline = api.tagline()
|
||||||
votecount = None
|
votecount = None
|
||||||
collections = api.getCollections()
|
collections = api.collection_list()
|
||||||
|
|
||||||
rating = userdata['Rating']
|
rating = userdata['Rating']
|
||||||
year = api.getYear()
|
year = api.year()
|
||||||
premieredate = api.getPremiereDate()
|
premieredate = api.premiere_date()
|
||||||
imdb = api.getProvider('imdb')
|
imdb = api.provider('imdb')
|
||||||
mpaa = api.getMpaa()
|
mpaa = api.content_rating()
|
||||||
countries = api.getCountry()
|
countries = api.country_list()
|
||||||
country = api.joinList(countries)
|
country = api.list_to_string(countries)
|
||||||
studios = api.getStudios()
|
studios = api.music_studio_list()
|
||||||
try:
|
try:
|
||||||
studio = studios[0]
|
studio = studios[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
@ -257,7 +257,7 @@ class Movies(Items):
|
||||||
|
|
||||||
# Find one trailer
|
# Find one trailer
|
||||||
trailer = None
|
trailer = None
|
||||||
extras = api.getExtras()
|
extras = api.extras_list()
|
||||||
for extra in extras:
|
for extra in extras:
|
||||||
# Only get 1st trailer element
|
# Only get 1st trailer element
|
||||||
if extra['extraType'] == 1:
|
if extra['extraType'] == 1:
|
||||||
|
@ -269,12 +269,12 @@ class Movies(Items):
|
||||||
do_indirect = not state.DIRECT_PATHS
|
do_indirect = not state.DIRECT_PATHS
|
||||||
if state.DIRECT_PATHS:
|
if state.DIRECT_PATHS:
|
||||||
# Direct paths is set the Kodi way
|
# Direct paths is set the Kodi way
|
||||||
playurl = api.getFilePath(forceFirstMediaStream=True)
|
playurl = api.file_path(force_first_media=True)
|
||||||
if playurl is None:
|
if playurl is None:
|
||||||
# Something went wrong, trying to use non-direct paths
|
# Something went wrong, trying to use non-direct paths
|
||||||
do_indirect = True
|
do_indirect = True
|
||||||
else:
|
else:
|
||||||
playurl = api.validatePlayurl(playurl, api.getType())
|
playurl = api.validate_playurl(playurl, api.plex_type())
|
||||||
if playurl is None:
|
if playurl is None:
|
||||||
return False
|
return False
|
||||||
if "\\" in playurl:
|
if "\\" in playurl:
|
||||||
|
@ -439,13 +439,13 @@ class Movies(Items):
|
||||||
# Process countries
|
# Process countries
|
||||||
self.kodi_db.addCountries(movieid, countries, "movie")
|
self.kodi_db.addCountries(movieid, countries, "movie")
|
||||||
# Process cast
|
# Process cast
|
||||||
self.kodi_db.addPeople(movieid, api.getPeopleList(), "movie")
|
self.kodi_db.addPeople(movieid, api.people_list(), "movie")
|
||||||
# Process genres
|
# Process genres
|
||||||
self.kodi_db.addGenres(movieid, genres, "movie")
|
self.kodi_db.addGenres(movieid, genres, "movie")
|
||||||
# Process artwork
|
# Process artwork
|
||||||
artwork.addArtwork(api.getAllArtwork(), movieid, "movie", kodicursor)
|
artwork.addArtwork(api.artwork(), movieid, "movie", kodicursor)
|
||||||
# Process stream details
|
# Process stream details
|
||||||
self.kodi_db.addStreams(fileid, api.getMediaStreams(), runtime)
|
self.kodi_db.addStreams(fileid, api.mediastreams(), runtime)
|
||||||
# Process studios
|
# Process studios
|
||||||
self.kodi_db.addStudios(movieid, studios, "movie")
|
self.kodi_db.addStudios(movieid, studios, "movie")
|
||||||
# Process tags: view, Plex collection tags
|
# Process tags: view, Plex collection tags
|
||||||
|
@ -520,7 +520,7 @@ class TVShows(Items):
|
||||||
api = API(item)
|
api = API(item)
|
||||||
|
|
||||||
update_item = True
|
update_item = True
|
||||||
itemid = api.getRatingKey()
|
itemid = api.plex_id()
|
||||||
|
|
||||||
if not itemid:
|
if not itemid:
|
||||||
LOG.error("Cannot parse XML data for TV show")
|
LOG.error("Cannot parse XML data for TV show")
|
||||||
|
@ -548,20 +548,20 @@ class TVShows(Items):
|
||||||
showid)
|
showid)
|
||||||
|
|
||||||
# fileId information
|
# fileId information
|
||||||
checksum = api.getChecksum()
|
checksum = api.checksum()
|
||||||
|
|
||||||
# item details
|
# item details
|
||||||
genres = api.getGenres()
|
genres = api.genre_list()
|
||||||
title, sorttitle = api.getTitle()
|
title, sorttitle = api.titles()
|
||||||
plot = api.getPlot()
|
plot = api.plot()
|
||||||
rating = api.getAudienceRating()
|
rating = api.audience_rating()
|
||||||
votecount = None
|
votecount = None
|
||||||
premieredate = api.getPremiereDate()
|
premieredate = api.premiere_date()
|
||||||
tvdb = api.getProvider('tvdb')
|
tvdb = api.provider('tvdb')
|
||||||
mpaa = api.getMpaa()
|
mpaa = api.content_rating()
|
||||||
genre = api.joinList(genres)
|
genre = api.list_to_string(genres)
|
||||||
studios = api.getStudios()
|
studios = api.music_studio_list()
|
||||||
collections = api.getCollections()
|
collections = api.collection_list()
|
||||||
try:
|
try:
|
||||||
studio = studios[0]
|
studio = studios[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
@ -571,13 +571,13 @@ class TVShows(Items):
|
||||||
do_indirect = not state.DIRECT_PATHS
|
do_indirect = not state.DIRECT_PATHS
|
||||||
if state.DIRECT_PATHS:
|
if state.DIRECT_PATHS:
|
||||||
# Direct paths is set the Kodi way
|
# Direct paths is set the Kodi way
|
||||||
playurl = api.getTVShowPath()
|
playurl = api.tv_show_path()
|
||||||
if playurl is None:
|
if playurl is None:
|
||||||
# Something went wrong, trying to use non-direct paths
|
# Something went wrong, trying to use non-direct paths
|
||||||
do_indirect = True
|
do_indirect = True
|
||||||
else:
|
else:
|
||||||
playurl = api.validatePlayurl(playurl,
|
playurl = api.validate_playurl(playurl,
|
||||||
api.getType(),
|
api.plex_type(),
|
||||||
folder=True)
|
folder=True)
|
||||||
if playurl is None:
|
if playurl is None:
|
||||||
return False
|
return False
|
||||||
|
@ -728,12 +728,12 @@ class TVShows(Items):
|
||||||
kodicursor.execute(query, (path, None, None, 1, toppathid, pathid))
|
kodicursor.execute(query, (path, None, None, 1, toppathid, pathid))
|
||||||
|
|
||||||
# Process cast
|
# Process cast
|
||||||
people = api.getPeopleList()
|
people = api.people_list()
|
||||||
self.kodi_db.addPeople(showid, people, "tvshow")
|
self.kodi_db.addPeople(showid, people, "tvshow")
|
||||||
# Process genres
|
# Process genres
|
||||||
self.kodi_db.addGenres(showid, genres, "tvshow")
|
self.kodi_db.addGenres(showid, genres, "tvshow")
|
||||||
# Process artwork
|
# Process artwork
|
||||||
allartworks = api.getAllArtwork()
|
allartworks = api.artwork()
|
||||||
artwork.addArtwork(allartworks, showid, "tvshow", kodicursor)
|
artwork.addArtwork(allartworks, showid, "tvshow", kodicursor)
|
||||||
# Process studios
|
# Process studios
|
||||||
self.kodi_db.addStudios(showid, studios, "tvshow")
|
self.kodi_db.addStudios(showid, studios, "tvshow")
|
||||||
|
@ -748,14 +748,14 @@ class TVShows(Items):
|
||||||
Process a single season of a certain tv show
|
Process a single season of a certain tv show
|
||||||
"""
|
"""
|
||||||
api = API(item)
|
api = API(item)
|
||||||
plex_id = api.getRatingKey()
|
plex_id = api.plex_id()
|
||||||
if not plex_id:
|
if not plex_id:
|
||||||
LOG.error('Error getting plex_id for season, skipping')
|
LOG.error('Error getting plex_id for season, skipping')
|
||||||
return
|
return
|
||||||
kodicursor = self.kodicursor
|
kodicursor = self.kodicursor
|
||||||
plex_db = self.plex_db
|
plex_db = self.plex_db
|
||||||
artwork = self.artwork
|
artwork = self.artwork
|
||||||
seasonnum = api.getIndex()
|
seasonnum = api.season_number()
|
||||||
# Get parent tv show Plex id
|
# Get parent tv show Plex id
|
||||||
plexshowid = item.attrib.get('parentRatingKey')
|
plexshowid = item.attrib.get('parentRatingKey')
|
||||||
# Get Kodi showid
|
# Get Kodi showid
|
||||||
|
@ -768,13 +768,13 @@ class TVShows(Items):
|
||||||
return
|
return
|
||||||
|
|
||||||
seasonid = self.kodi_db.addSeason(showid, seasonnum)
|
seasonid = self.kodi_db.addSeason(showid, seasonnum)
|
||||||
checksum = api.getChecksum()
|
checksum = api.checksum()
|
||||||
# Check whether Season already exists
|
# Check whether Season already exists
|
||||||
plex_dbitem = plex_db.getItem_byId(plex_id)
|
plex_dbitem = plex_db.getItem_byId(plex_id)
|
||||||
update_item = False if plex_dbitem is None else True
|
update_item = False if plex_dbitem is None else True
|
||||||
|
|
||||||
# Process artwork
|
# Process artwork
|
||||||
allartworks = api.getAllArtwork()
|
allartworks = api.artwork()
|
||||||
artwork.addArtwork(allartworks, seasonid, "season", kodicursor)
|
artwork.addArtwork(allartworks, seasonid, "season", kodicursor)
|
||||||
|
|
||||||
if update_item:
|
if update_item:
|
||||||
|
@ -804,7 +804,7 @@ class TVShows(Items):
|
||||||
# item update
|
# item update
|
||||||
# If the item doesn't exist, we'll add it to the database
|
# If the item doesn't exist, we'll add it to the database
|
||||||
update_item = True
|
update_item = True
|
||||||
itemid = api.getRatingKey()
|
itemid = api.plex_id()
|
||||||
if not itemid:
|
if not itemid:
|
||||||
LOG.error('Error getting itemid for episode, skipping')
|
LOG.error('Error getting itemid for episode, skipping')
|
||||||
return
|
return
|
||||||
|
@ -832,26 +832,26 @@ class TVShows(Items):
|
||||||
episodeid)
|
episodeid)
|
||||||
|
|
||||||
# fileId information
|
# fileId information
|
||||||
checksum = api.getChecksum()
|
checksum = api.checksum()
|
||||||
dateadded = api.getDateCreated()
|
dateadded = api.date_created()
|
||||||
userdata = api.getUserData()
|
userdata = api.userdata()
|
||||||
playcount = userdata['PlayCount']
|
playcount = userdata['PlayCount']
|
||||||
dateplayed = userdata['LastPlayedDate']
|
dateplayed = userdata['LastPlayedDate']
|
||||||
tvdb = api.getProvider('tvdb')
|
tvdb = api.provider('tvdb')
|
||||||
votecount = None
|
votecount = None
|
||||||
|
|
||||||
# item details
|
# item details
|
||||||
peoples = api.getPeople()
|
peoples = api.people()
|
||||||
director = api.joinList(peoples['Director'])
|
director = api.list_to_string(peoples['Director'])
|
||||||
writer = api.joinList(peoples['Writer'])
|
writer = api.list_to_string(peoples['Writer'])
|
||||||
title, _ = api.getTitle()
|
title, _ = api.titles()
|
||||||
plot = api.getPlot()
|
plot = api.plot()
|
||||||
rating = userdata['Rating']
|
rating = userdata['Rating']
|
||||||
resume, runtime = api.getRuntime()
|
resume, runtime = api.resume_runtime()
|
||||||
premieredate = api.getPremiereDate()
|
premieredate = api.premiere_date()
|
||||||
|
|
||||||
# episode details
|
# episode details
|
||||||
series_id, _, season, episode = api.getEpisodeDetails()
|
series_id, _, season, episode = api.episode_data()
|
||||||
|
|
||||||
if season is None:
|
if season is None:
|
||||||
season = -1
|
season = -1
|
||||||
|
@ -886,14 +886,14 @@ class TVShows(Items):
|
||||||
|
|
||||||
# GET THE FILE AND PATH #####
|
# GET THE FILE AND PATH #####
|
||||||
do_indirect = not state.DIRECT_PATHS
|
do_indirect = not state.DIRECT_PATHS
|
||||||
playurl = api.getFilePath(forceFirstMediaStream=True)
|
playurl = api.file_path(force_first_media=True)
|
||||||
if state.DIRECT_PATHS:
|
if state.DIRECT_PATHS:
|
||||||
# Direct paths is set the Kodi way
|
# Direct paths is set the Kodi way
|
||||||
if playurl is None:
|
if playurl is None:
|
||||||
# Something went wrong, trying to use non-direct paths
|
# Something went wrong, trying to use non-direct paths
|
||||||
do_indirect = True
|
do_indirect = True
|
||||||
else:
|
else:
|
||||||
playurl = api.validatePlayurl(playurl, api.getType())
|
playurl = api.validate_playurl(playurl, api.plex_type())
|
||||||
if playurl is None:
|
if playurl is None:
|
||||||
return False
|
return False
|
||||||
if "\\" in playurl:
|
if "\\" in playurl:
|
||||||
|
@ -1081,19 +1081,19 @@ class TVShows(Items):
|
||||||
))
|
))
|
||||||
kodicursor.execute(query, (pathid, filename, dateadded, fileid))
|
kodicursor.execute(query, (pathid, filename, dateadded, fileid))
|
||||||
# Process cast
|
# Process cast
|
||||||
people = api.getPeopleList()
|
people = api.people_list()
|
||||||
self.kodi_db.addPeople(episodeid, people, "episode")
|
self.kodi_db.addPeople(episodeid, people, "episode")
|
||||||
# Process artwork
|
# Process artwork
|
||||||
# Wide "screenshot" of particular episode
|
# Wide "screenshot" of particular episode
|
||||||
poster = item.attrib.get('thumb')
|
poster = item.attrib.get('thumb')
|
||||||
if poster:
|
if poster:
|
||||||
poster = api.addPlexCredentialsToUrl(
|
poster = api.attach_plex_token_to_url(
|
||||||
"%s%s" % (self.server, poster))
|
"%s%s" % (self.server, poster))
|
||||||
artwork.addOrUpdateArt(
|
artwork.addOrUpdateArt(
|
||||||
poster, episodeid, "episode", "thumb", kodicursor)
|
poster, episodeid, "episode", "thumb", kodicursor)
|
||||||
|
|
||||||
# Process stream details
|
# Process stream details
|
||||||
streams = api.getMediaStreams()
|
streams = api.mediastreams()
|
||||||
self.kodi_db.addStreams(fileid, streams, runtime)
|
self.kodi_db.addStreams(fileid, streams, runtime)
|
||||||
# Process playstates
|
# Process playstates
|
||||||
self.kodi_db.addPlaystate(fileid,
|
self.kodi_db.addPlaystate(fileid,
|
||||||
|
@ -1293,7 +1293,7 @@ class Music(Items):
|
||||||
api = API(item)
|
api = API(item)
|
||||||
|
|
||||||
update_item = True
|
update_item = True
|
||||||
itemid = api.getRatingKey()
|
itemid = api.plex_id()
|
||||||
plex_dbitem = plex_db.getItem_byId(itemid)
|
plex_dbitem = plex_db.getItem_byId(itemid)
|
||||||
try:
|
try:
|
||||||
artistid = plex_dbitem[0]
|
artistid = plex_dbitem[0]
|
||||||
|
@ -1302,17 +1302,17 @@ class Music(Items):
|
||||||
|
|
||||||
# The artist details #####
|
# The artist details #####
|
||||||
lastScraped = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
lastScraped = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
dateadded = api.getDateCreated()
|
dateadded = api.date_created()
|
||||||
checksum = api.getChecksum()
|
checksum = api.checksum()
|
||||||
|
|
||||||
name, _ = api.getTitle()
|
name, _ = api.titles()
|
||||||
# musicBrainzId = api.getProvider('MusicBrainzArtist')
|
# musicBrainzId = api.provider('MusicBrainzArtist')
|
||||||
musicBrainzId = None
|
musicBrainzId = None
|
||||||
genres = ' / '.join(api.getGenres())
|
genres = ' / '.join(api.genre_list())
|
||||||
bio = api.getPlot()
|
bio = api.plot()
|
||||||
|
|
||||||
# Associate artwork
|
# Associate artwork
|
||||||
artworks = api.getAllArtwork(parentInfo=True)
|
artworks = api.artwork(parent_info=True)
|
||||||
thumb = artworks['Primary']
|
thumb = artworks['Primary']
|
||||||
backdrops = artworks['Backdrop'] # List
|
backdrops = artworks['Backdrop'] # List
|
||||||
|
|
||||||
|
@ -1381,7 +1381,7 @@ class Music(Items):
|
||||||
api = API(item)
|
api = API(item)
|
||||||
|
|
||||||
update_item = True
|
update_item = True
|
||||||
itemid = api.getRatingKey()
|
itemid = api.plex_id()
|
||||||
if not itemid:
|
if not itemid:
|
||||||
LOG.error('Error processing Album, skipping')
|
LOG.error('Error processing Album, skipping')
|
||||||
return
|
return
|
||||||
|
@ -1394,19 +1394,19 @@ class Music(Items):
|
||||||
|
|
||||||
# The album details #####
|
# The album details #####
|
||||||
lastScraped = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
lastScraped = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
dateadded = api.getDateCreated()
|
dateadded = api.date_created()
|
||||||
userdata = api.getUserData()
|
userdata = api.userdata()
|
||||||
checksum = api.getChecksum()
|
checksum = api.checksum()
|
||||||
|
|
||||||
name, _ = api.getTitle()
|
name, _ = api.titles()
|
||||||
# musicBrainzId = api.getProvider('MusicBrainzAlbum')
|
# musicBrainzId = api.provider('MusicBrainzAlbum')
|
||||||
musicBrainzId = None
|
musicBrainzId = None
|
||||||
year = api.getYear()
|
year = api.year()
|
||||||
self.genres = api.getGenres()
|
self.genres = api.genre_list()
|
||||||
self.genre = ' / '.join(self.genres)
|
self.genre = ' / '.join(self.genres)
|
||||||
bio = api.getPlot()
|
bio = api.plot()
|
||||||
rating = userdata['UserRating']
|
rating = userdata['UserRating']
|
||||||
studio = api.getMusicStudio()
|
studio = api.music_studio()
|
||||||
artistname = item.attrib.get('parentTitle')
|
artistname = item.attrib.get('parentTitle')
|
||||||
if not artistname:
|
if not artistname:
|
||||||
artistname = item.attrib.get('originalTitle')
|
artistname = item.attrib.get('originalTitle')
|
||||||
|
@ -1418,7 +1418,7 @@ class Music(Items):
|
||||||
self.compilation = 1
|
self.compilation = 1
|
||||||
break
|
break
|
||||||
# Associate artwork
|
# Associate artwork
|
||||||
artworks = api.getAllArtwork(parentInfo=True)
|
artworks = api.artwork(parent_info=True)
|
||||||
thumb = artworks['Primary']
|
thumb = artworks['Primary']
|
||||||
if thumb:
|
if thumb:
|
||||||
thumb = "<thumb>%s</thumb>" % thumb
|
thumb = "<thumb>%s</thumb>" % thumb
|
||||||
|
@ -1576,7 +1576,7 @@ class Music(Items):
|
||||||
api = API(item)
|
api = API(item)
|
||||||
|
|
||||||
update_item = True
|
update_item = True
|
||||||
itemid = api.getRatingKey()
|
itemid = api.plex_id()
|
||||||
if not itemid:
|
if not itemid:
|
||||||
LOG.error('Error processing Song; skipping')
|
LOG.error('Error processing Song; skipping')
|
||||||
return
|
return
|
||||||
|
@ -1592,9 +1592,9 @@ class Music(Items):
|
||||||
songid = kodicursor.fetchone()[0] + 1
|
songid = kodicursor.fetchone()[0] + 1
|
||||||
|
|
||||||
# The song details #####
|
# The song details #####
|
||||||
checksum = api.getChecksum()
|
checksum = api.checksum()
|
||||||
dateadded = api.getDateCreated()
|
dateadded = api.date_created()
|
||||||
userdata = api.getUserData()
|
userdata = api.userdata()
|
||||||
playcount = userdata['PlayCount']
|
playcount = userdata['PlayCount']
|
||||||
if playcount is None:
|
if playcount is None:
|
||||||
# This is different to Video DB!
|
# This is different to Video DB!
|
||||||
|
@ -1602,8 +1602,8 @@ class Music(Items):
|
||||||
dateplayed = userdata['LastPlayedDate']
|
dateplayed = userdata['LastPlayedDate']
|
||||||
|
|
||||||
# item details
|
# item details
|
||||||
title, _ = api.getTitle()
|
title, _ = api.titles()
|
||||||
# musicBrainzId = api.getProvider('MusicBrainzTrackId')
|
# musicBrainzId = api.provider('MusicBrainzTrackId')
|
||||||
musicBrainzId = None
|
musicBrainzId = None
|
||||||
try:
|
try:
|
||||||
genres = self.genres
|
genres = self.genres
|
||||||
|
@ -1627,8 +1627,8 @@ class Music(Items):
|
||||||
track = tracknumber
|
track = tracknumber
|
||||||
else:
|
else:
|
||||||
track = disc*2**16 + tracknumber
|
track = disc*2**16 + tracknumber
|
||||||
year = api.getYear()
|
year = api.year()
|
||||||
_, duration = api.getRuntime()
|
_, duration = api.resume_runtime()
|
||||||
rating = userdata['UserRating']
|
rating = userdata['UserRating']
|
||||||
comment = None
|
comment = None
|
||||||
# Moods
|
# Moods
|
||||||
|
@ -1642,12 +1642,12 @@ class Music(Items):
|
||||||
do_indirect = not state.DIRECT_PATHS
|
do_indirect = not state.DIRECT_PATHS
|
||||||
if state.DIRECT_PATHS:
|
if state.DIRECT_PATHS:
|
||||||
# Direct paths is set the Kodi way
|
# Direct paths is set the Kodi way
|
||||||
playurl = api.getFilePath(forceFirstMediaStream=True)
|
playurl = api.file_path(force_first_media=True)
|
||||||
if playurl is None:
|
if playurl is None:
|
||||||
# Something went wrong, trying to use non-direct paths
|
# Something went wrong, trying to use non-direct paths
|
||||||
do_indirect = True
|
do_indirect = True
|
||||||
else:
|
else:
|
||||||
playurl = api.validatePlayurl(playurl, api.getType())
|
playurl = api.validate_playurl(playurl, api.plex_type())
|
||||||
if playurl is None:
|
if playurl is None:
|
||||||
return False
|
return False
|
||||||
if "\\" in playurl:
|
if "\\" in playurl:
|
||||||
|
@ -1660,7 +1660,7 @@ class Music(Items):
|
||||||
if do_indirect:
|
if do_indirect:
|
||||||
# Plex works a bit differently
|
# Plex works a bit differently
|
||||||
path = "%s%s" % (self.server, item[0][0].attrib.get('key'))
|
path = "%s%s" % (self.server, item[0][0].attrib.get('key'))
|
||||||
path = api.addPlexCredentialsToUrl(path)
|
path = api.attach_plex_token_to_url(path)
|
||||||
filename = path.rsplit('/', 1)[1]
|
filename = path.rsplit('/', 1)[1]
|
||||||
path = path.replace(filename, '')
|
path = path.replace(filename, '')
|
||||||
|
|
||||||
|
@ -1710,7 +1710,7 @@ class Music(Items):
|
||||||
itemid)
|
itemid)
|
||||||
albumid = self.kodi_db.addAlbum(
|
albumid = self.kodi_db.addAlbum(
|
||||||
album_name,
|
album_name,
|
||||||
api.getProvider('MusicBrainzAlbum'))
|
api.provider('MusicBrainzAlbum'))
|
||||||
plex_db.addReference("%salbum%s" % (itemid, albumid),
|
plex_db.addReference("%salbum%s" % (itemid, albumid),
|
||||||
v.PLEX_TYPE_ALBUM,
|
v.PLEX_TYPE_ALBUM,
|
||||||
albumid,
|
albumid,
|
||||||
|
@ -1854,7 +1854,7 @@ class Music(Items):
|
||||||
if genres:
|
if genres:
|
||||||
self.kodi_db.addMusicGenres(songid, genres, v.KODI_TYPE_SONG)
|
self.kodi_db.addMusicGenres(songid, genres, v.KODI_TYPE_SONG)
|
||||||
# Update artwork
|
# Update artwork
|
||||||
allart = api.getAllArtwork(parentInfo=True)
|
allart = api.artwork(parent_info=True)
|
||||||
artwork.addArtwork(allart, songid, v.KODI_TYPE_SONG, kodicursor)
|
artwork.addArtwork(allart, songid, v.KODI_TYPE_SONG, kodicursor)
|
||||||
if item.get('parentKey') is None:
|
if item.get('parentKey') is None:
|
||||||
# Update album artwork
|
# Update album artwork
|
||||||
|
|
|
@ -766,7 +766,7 @@ class Kodidb_Functions():
|
||||||
)
|
)
|
||||||
self.cursor.execute(query, (fileid, 2, subtitletrack))
|
self.cursor.execute(query, (fileid, 2, subtitletrack))
|
||||||
|
|
||||||
def getResumes(self):
|
def resume_points(self):
|
||||||
"""
|
"""
|
||||||
VIDEOS
|
VIDEOS
|
||||||
|
|
||||||
|
|
|
@ -568,7 +568,7 @@ class LibrarySync(Thread):
|
||||||
|
|
||||||
Output: self.updatelist, self.allPlexElementsId
|
Output: self.updatelist, self.allPlexElementsId
|
||||||
self.updatelist APPENDED(!!) list itemids (Plex Keys as
|
self.updatelist APPENDED(!!) list itemids (Plex Keys as
|
||||||
as received from API.getRatingKey())
|
as received from API.plex_id())
|
||||||
One item in this list is of the form:
|
One item in this list is of the form:
|
||||||
'itemId': xxx,
|
'itemId': xxx,
|
||||||
'itemType': 'Movies','TVShows', ...
|
'itemType': 'Movies','TVShows', ...
|
||||||
|
@ -744,7 +744,7 @@ class LibrarySync(Thread):
|
||||||
# Pull the list of movies and boxsets in Kodi
|
# Pull the list of movies and boxsets in Kodi
|
||||||
try:
|
try:
|
||||||
self.allKodiElementsId = dict(
|
self.allKodiElementsId = dict(
|
||||||
plex_db.getChecksum(v.PLEX_TYPE_MOVIE))
|
plex_db.checksum(v.PLEX_TYPE_MOVIE))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.allKodiElementsId = {}
|
self.allKodiElementsId = {}
|
||||||
|
|
||||||
|
@ -836,7 +836,7 @@ class LibrarySync(Thread):
|
||||||
v.PLEX_TYPE_SEASON,
|
v.PLEX_TYPE_SEASON,
|
||||||
v.PLEX_TYPE_EPISODE):
|
v.PLEX_TYPE_EPISODE):
|
||||||
try:
|
try:
|
||||||
elements = dict(plex.getChecksum(kind))
|
elements = dict(plex.checksum(kind))
|
||||||
self.allKodiElementsId.update(elements)
|
self.allKodiElementsId.update(elements)
|
||||||
# Yet empty/not yet synched
|
# Yet empty/not yet synched
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -1009,7 +1009,7 @@ class LibrarySync(Thread):
|
||||||
with plexdb.Get_Plex_DB() as plex_db:
|
with plexdb.Get_Plex_DB() as plex_db:
|
||||||
# Pull the list of items already in Kodi
|
# Pull the list of items already in Kodi
|
||||||
try:
|
try:
|
||||||
elements = dict(plex_db.getChecksum(kind))
|
elements = dict(plex_db.checksum(kind))
|
||||||
self.allKodiElementsId.update(elements)
|
self.allKodiElementsId.update(elements)
|
||||||
# Yet empty/nothing yet synched
|
# Yet empty/nothing yet synched
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -1349,7 +1349,7 @@ class LibrarySync(Thread):
|
||||||
plex_id)
|
plex_id)
|
||||||
continue
|
continue
|
||||||
api = PlexAPI.API(xml[0])
|
api = PlexAPI.API(xml[0])
|
||||||
userdata = api.getUserData()
|
userdata = api.userdata()
|
||||||
session['duration'] = userdata['Runtime']
|
session['duration'] = userdata['Runtime']
|
||||||
session['viewCount'] = userdata['PlayCount']
|
session['viewCount'] = userdata['PlayCount']
|
||||||
# Sometimes, Plex tells us resume points in milliseconds and
|
# Sometimes, Plex tells us resume points in milliseconds and
|
||||||
|
|
|
@ -38,9 +38,9 @@ def excludefromscan_music_folders():
|
||||||
continue
|
continue
|
||||||
for location in library:
|
for location in library:
|
||||||
if location.tag == 'Location':
|
if location.tag == 'Location':
|
||||||
path = api.validatePlayurl(location.attrib['path'],
|
path = api.validate_playurl(location.attrib['path'],
|
||||||
typus=v.PLEX_TYPE_ARTIST,
|
typus=v.PLEX_TYPE_ARTIST,
|
||||||
omitCheck=True)
|
omit_check=True)
|
||||||
paths.append(__turn_to_regex(path))
|
paths.append(__turn_to_regex(path))
|
||||||
try:
|
try:
|
||||||
with XmlKodiSetting('advancedsettings.xml',
|
with XmlKodiSetting('advancedsettings.xml',
|
||||||
|
|
|
@ -94,7 +94,7 @@ def playback_init(plex_id, plex_type, playqueue):
|
||||||
return
|
return
|
||||||
trailers = False
|
trailers = False
|
||||||
api = API(xml[0])
|
api = API(xml[0])
|
||||||
if (plex_type == v.PLEX_TYPE_MOVIE and not api.getResume() and
|
if (plex_type == v.PLEX_TYPE_MOVIE and not api.resume_point() and
|
||||||
settings('enableCinema') == "true"):
|
settings('enableCinema') == "true"):
|
||||||
if settings('askCinema') == "true":
|
if settings('askCinema') == "true":
|
||||||
# "Play trailers?"
|
# "Play trailers?"
|
||||||
|
@ -144,11 +144,11 @@ def _prep_playlist_stack(xml):
|
||||||
for item in xml:
|
for item in xml:
|
||||||
api = API(item)
|
api = API(item)
|
||||||
if (state.CONTEXT_MENU_PLAY is False and
|
if (state.CONTEXT_MENU_PLAY is False and
|
||||||
api.getType() != v.PLEX_TYPE_CLIP):
|
api.plex_type() != v.PLEX_TYPE_CLIP):
|
||||||
# If user chose to play via PMS or force transcode, do not
|
# If user chose to play via PMS or force transcode, do not
|
||||||
# use the item path stored in the Kodi DB
|
# use the item path stored in the Kodi DB
|
||||||
with plexdb.Get_Plex_DB() as plex_db:
|
with plexdb.Get_Plex_DB() as plex_db:
|
||||||
plex_dbitem = plex_db.getItem_byId(api.getRatingKey())
|
plex_dbitem = plex_db.getItem_byId(api.plex_id())
|
||||||
kodi_id = plex_dbitem[0] if plex_dbitem else None
|
kodi_id = plex_dbitem[0] if plex_dbitem else None
|
||||||
kodi_type = plex_dbitem[4] if plex_dbitem else None
|
kodi_type = plex_dbitem[4] if plex_dbitem else None
|
||||||
else:
|
else:
|
||||||
|
@ -156,17 +156,17 @@ def _prep_playlist_stack(xml):
|
||||||
kodi_id = None
|
kodi_id = None
|
||||||
kodi_type = None
|
kodi_type = None
|
||||||
for part, _ in enumerate(item[0]):
|
for part, _ in enumerate(item[0]):
|
||||||
api.setPartNumber(part)
|
api.set_part_number(part)
|
||||||
if kodi_id is None:
|
if kodi_id is None:
|
||||||
# Need to redirect again to PKC to conclude playback
|
# Need to redirect again to PKC to conclude playback
|
||||||
params = {
|
params = {
|
||||||
'mode': 'play',
|
'mode': 'play',
|
||||||
'plex_id': api.getRatingKey(),
|
'plex_id': api.plex_id(),
|
||||||
'plex_type': api.getType()
|
'plex_type': api.plex_type()
|
||||||
}
|
}
|
||||||
path = ('plugin://plugin.video.plexkodiconnect?%s'
|
path = ('plugin://plugin.video.plexkodiconnect?%s'
|
||||||
% urlencode(params))
|
% urlencode(params))
|
||||||
listitem = api.CreateListItemFromPlexItem()
|
listitem = api.create_listitem()
|
||||||
listitem.setPath(try_encode(path))
|
listitem.setPath(try_encode(path))
|
||||||
else:
|
else:
|
||||||
# Will add directly via the Kodi DB
|
# Will add directly via the Kodi DB
|
||||||
|
@ -179,9 +179,9 @@ def _prep_playlist_stack(xml):
|
||||||
'xml_video_element': item,
|
'xml_video_element': item,
|
||||||
'listitem': listitem,
|
'listitem': listitem,
|
||||||
'part': part,
|
'part': part,
|
||||||
'playcount': api.getViewCount(),
|
'playcount': api.viewcount(),
|
||||||
'offset': api.getResume(),
|
'offset': api.resume_point(),
|
||||||
'id': api.getItemId()
|
'id': api.item_id()
|
||||||
})
|
})
|
||||||
return stack
|
return stack
|
||||||
|
|
||||||
|
@ -238,15 +238,15 @@ def conclude_playback(playqueue, pos):
|
||||||
if item.xml is not None:
|
if item.xml is not None:
|
||||||
# Got a Plex element
|
# Got a Plex element
|
||||||
api = API(item.xml)
|
api = API(item.xml)
|
||||||
api.setPartNumber(item.part)
|
api.set_part_number(item.part)
|
||||||
api.CreateListItemFromPlexItem(listitem)
|
api.create_listitem(listitem)
|
||||||
playutils = PlayUtils(api, item)
|
playutils = PlayUtils(api, item)
|
||||||
playurl = playutils.getPlayUrl()
|
playurl = playutils.getPlayUrl()
|
||||||
else:
|
else:
|
||||||
playurl = item.file
|
playurl = item.file
|
||||||
listitem.setPath(try_encode(playurl))
|
listitem.setPath(try_encode(playurl))
|
||||||
if item.playmethod in ('DirectStream', 'DirectPlay'):
|
if item.playmethod in ('DirectStream', 'DirectPlay'):
|
||||||
listitem.setSubtitles(api.externalSubs())
|
listitem.setSubtitles(api.cache_external_subs())
|
||||||
else:
|
else:
|
||||||
playutils.audio_subtitle_prefs(listitem)
|
playutils.audio_subtitle_prefs(listitem)
|
||||||
if state.RESUME_PLAYBACK is True:
|
if state.RESUME_PLAYBACK is True:
|
||||||
|
@ -300,9 +300,9 @@ def process_indirect(key, offset, resolve=True):
|
||||||
# Todo: implement offset
|
# Todo: implement offset
|
||||||
api = API(xml[0])
|
api = API(xml[0])
|
||||||
listitem = PKC_ListItem()
|
listitem = PKC_ListItem()
|
||||||
api.CreateListItemFromPlexItem(listitem)
|
api.create_listitem(listitem)
|
||||||
playqueue = PQ.get_playqueue_from_type(
|
playqueue = PQ.get_playqueue_from_type(
|
||||||
v.KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE[api.getType()])
|
v.KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE[api.plex_type()])
|
||||||
playqueue.clear()
|
playqueue.clear()
|
||||||
item = PL.Playlist_Item()
|
item = PL.Playlist_Item()
|
||||||
item.xml = xml[0]
|
item.xml = xml[0]
|
||||||
|
|
|
@ -280,8 +280,8 @@ def playlist_item_from_xml(playlist, xml_video_element, kodi_id=None,
|
||||||
"""
|
"""
|
||||||
item = Playlist_Item()
|
item = Playlist_Item()
|
||||||
api = API(xml_video_element)
|
api = API(xml_video_element)
|
||||||
item.plex_id = api.getRatingKey()
|
item.plex_id = api.plex_id()
|
||||||
item.plex_type = api.getType()
|
item.plex_type = api.plex_type()
|
||||||
try:
|
try:
|
||||||
item.id = xml_video_element.attrib['%sItemID' % playlist.kind]
|
item.id = xml_video_element.attrib['%sItemID' % playlist.kind]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
|
@ -91,7 +91,7 @@ def init_playqueue_from_plex_children(plex_id, transient_token=None):
|
||||||
playqueue.clear()
|
playqueue.clear()
|
||||||
for i, child in enumerate(xml):
|
for i, child in enumerate(xml):
|
||||||
api = API(child)
|
api = API(child)
|
||||||
PL.add_item_to_playlist(playqueue, i, plex_id=api.getRatingKey())
|
PL.add_item_to_playlist(playqueue, i, plex_id=api.plex_id())
|
||||||
playqueue.plex_transient_token = transient_token
|
playqueue.plex_transient_token = transient_token
|
||||||
LOG.debug('Firing up Kodi player')
|
LOG.debug('Firing up Kodi player')
|
||||||
Player().play(playqueue.kodi_pl, None, False, 0)
|
Player().play(playqueue.kodi_pl, None, False, 0)
|
||||||
|
|
|
@ -29,18 +29,18 @@ class PlayUtils():
|
||||||
|
|
||||||
playurl is in unicode!
|
playurl is in unicode!
|
||||||
"""
|
"""
|
||||||
self.api.getMediastreamNumber()
|
self.api.mediastream_number()
|
||||||
playurl = self.isDirectPlay()
|
playurl = self.isDirectPlay()
|
||||||
if playurl is not None:
|
if playurl is not None:
|
||||||
LOG.info("File is direct playing.")
|
LOG.info("File is direct playing.")
|
||||||
self.item.playmethod = 'DirectPlay'
|
self.item.playmethod = 'DirectPlay'
|
||||||
elif self.isDirectStream():
|
elif self.isDirectStream():
|
||||||
LOG.info("File is direct streaming.")
|
LOG.info("File is direct streaming.")
|
||||||
playurl = self.api.getTranscodeVideoPath('DirectStream')
|
playurl = self.api.transcode_video_path('DirectStream')
|
||||||
self.item.playmethod = 'DirectStream'
|
self.item.playmethod = 'DirectStream'
|
||||||
else:
|
else:
|
||||||
LOG.info("File is transcoding.")
|
LOG.info("File is transcoding.")
|
||||||
playurl = self.api.getTranscodeVideoPath(
|
playurl = self.api.transcode_video_path(
|
||||||
'Transcode',
|
'Transcode',
|
||||||
quality={
|
quality={
|
||||||
'maxVideoBitrate': self.get_bitrate(),
|
'maxVideoBitrate': self.get_bitrate(),
|
||||||
|
@ -58,16 +58,16 @@ class PlayUtils():
|
||||||
Returns the path/playurl if we can direct play, None otherwise
|
Returns the path/playurl if we can direct play, None otherwise
|
||||||
"""
|
"""
|
||||||
# True for e.g. plex.tv watch later
|
# True for e.g. plex.tv watch later
|
||||||
if self.api.shouldStream() is True:
|
if self.api.should_stream() is True:
|
||||||
LOG.info("Plex item optimized for direct streaming")
|
LOG.info("Plex item optimized for direct streaming")
|
||||||
return
|
return
|
||||||
# Check whether we have a strm file that we need to throw at Kodi 1:1
|
# Check whether we have a strm file that we need to throw at Kodi 1:1
|
||||||
path = self.api.getFilePath()
|
path = self.api.file_path()
|
||||||
if path is not None and path.endswith('.strm'):
|
if path is not None and path.endswith('.strm'):
|
||||||
LOG.info('.strm file detected')
|
LOG.info('.strm file detected')
|
||||||
playurl = self.api.validatePlayurl(path,
|
playurl = self.api.validate_playurl(path,
|
||||||
self.api.getType(),
|
self.api.plex_type(),
|
||||||
forceCheck=True)
|
force_check=True)
|
||||||
return playurl
|
return playurl
|
||||||
# set to either 'Direct Stream=1' or 'Transcode=2'
|
# set to either 'Direct Stream=1' or 'Transcode=2'
|
||||||
# and NOT to 'Direct Play=0'
|
# and NOT to 'Direct Play=0'
|
||||||
|
@ -77,9 +77,9 @@ class PlayUtils():
|
||||||
return
|
return
|
||||||
if self.mustTranscode():
|
if self.mustTranscode():
|
||||||
return
|
return
|
||||||
return self.api.validatePlayurl(path,
|
return self.api.validate_playurl(path,
|
||||||
self.api.getType(),
|
self.api.plex_type(),
|
||||||
forceCheck=True)
|
force_check=True)
|
||||||
|
|
||||||
def mustTranscode(self):
|
def mustTranscode(self):
|
||||||
"""
|
"""
|
||||||
|
@ -93,10 +93,10 @@ class PlayUtils():
|
||||||
- video bitrate above specified settings bitrate
|
- video bitrate above specified settings bitrate
|
||||||
if the corresponding file settings are set to 'true'
|
if the corresponding file settings are set to 'true'
|
||||||
"""
|
"""
|
||||||
if self.api.getType() in (v.PLEX_TYPE_CLIP, v.PLEX_TYPE_SONG):
|
if self.api.plex_type() in (v.PLEX_TYPE_CLIP, v.PLEX_TYPE_SONG):
|
||||||
LOG.info('Plex clip or music track, not transcoding')
|
LOG.info('Plex clip or music track, not transcoding')
|
||||||
return False
|
return False
|
||||||
videoCodec = self.api.getVideoCodec()
|
videoCodec = self.api.video_codec()
|
||||||
LOG.info("videoCodec: %s" % videoCodec)
|
LOG.info("videoCodec: %s" % videoCodec)
|
||||||
if self.item.force_transcode is True:
|
if self.item.force_transcode is True:
|
||||||
LOG.info('User chose to force-transcode')
|
LOG.info('User chose to force-transcode')
|
||||||
|
@ -136,7 +136,7 @@ class PlayUtils():
|
||||||
|
|
||||||
def isDirectStream(self):
|
def isDirectStream(self):
|
||||||
# Never transcode Music
|
# Never transcode Music
|
||||||
if self.api.getType() == 'track':
|
if self.api.plex_type() == 'track':
|
||||||
return True
|
return True
|
||||||
# set to 'Transcode=2'
|
# set to 'Transcode=2'
|
||||||
if settings('playType') == "2":
|
if settings('playType') == "2":
|
||||||
|
@ -232,7 +232,7 @@ class PlayUtils():
|
||||||
"""
|
"""
|
||||||
# Set media and part where we're at
|
# Set media and part where we're at
|
||||||
if self.api.mediastream is None:
|
if self.api.mediastream is None:
|
||||||
self.api.getMediastreamNumber()
|
self.api.mediastream_number()
|
||||||
try:
|
try:
|
||||||
mediastreams = self.api.plex_media_streams()
|
mediastreams = self.api.plex_media_streams()
|
||||||
except (TypeError, IndexError):
|
except (TypeError, IndexError):
|
||||||
|
@ -302,7 +302,7 @@ class PlayUtils():
|
||||||
stream.attrib['codec']))
|
stream.attrib['codec']))
|
||||||
# We don't know the language - no need to download
|
# We don't know the language - no need to download
|
||||||
else:
|
else:
|
||||||
path = self.api.addPlexCredentialsToUrl(
|
path = self.api.attach_plex_token_to_url(
|
||||||
"%s%s" % (window('pms_server'),
|
"%s%s" % (window('pms_server'),
|
||||||
stream.attrib['key']))
|
stream.attrib['key']))
|
||||||
downloadable_streams.append(index)
|
downloadable_streams.append(index)
|
||||||
|
|
|
@ -296,7 +296,7 @@ class Plex_DB_Functions():
|
||||||
self.plexcursor.execute(query, (parent_id, kodi_type,))
|
self.plexcursor.execute(query, (parent_id, kodi_type,))
|
||||||
return self.plexcursor.fetchall()
|
return self.plexcursor.fetchall()
|
||||||
|
|
||||||
def getChecksum(self, plex_type):
|
def checksum(self, plex_type):
|
||||||
"""
|
"""
|
||||||
Returns a list of tuples (plex_id, checksum) for plex_type
|
Returns a list of tuples (plex_id, checksum) for plex_type
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue