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