Add duration to info_labels

master
azzy9 3 months ago
parent c1d152ef2e
commit 75452cf912

@ -19,6 +19,8 @@ ADDON = xbmcaddon.Addon()
ADDON_ICON = ADDON.getAddonInfo('icon')
ADDON_NAME = ADDON.getAddonInfo('name')
KODI_VERSION = float(xbmcaddon.Addon('xbmc.addon').getAddonInfo('version')[:4])
#language
__language__ = ADDON.getLocalizedString
@ -123,6 +125,27 @@ def get_date_formatted( format_id, year, month, day ):
return day + '/' + month + '/' + year
return year + '/' + month + '/' + day
def duration_to_secs( duration, fail_return = '' ):
""" converts video duration to seconds """
if duration:
if ':' in duration:
time_element_amount = len( duration.split( ':' ) )
# ensure time sring is complete
if time_element_amount == 2:
duration = '0:' + duration
h, m, s = duration.split(':')
return str( int(h) * 3600 + int(m) * 60 + int(s) )
else:
# should only be seconds
return duration
return fail_return
def get_params():
""" gets params from request """
@ -148,3 +171,35 @@ def clean_text( text ):
text = text.replace(r'"', r'"').replace(r'&', r'&').replace(r''', r"'")
return text
def item_set_info( line_item, properties ):
""" line item set info """
if KODI_VERSION > 19.8:
vidtag = line_item.getVideoInfoTag()
if properties.get( 'year' ):
vidtag.setYear( properties.get( 'year' ) )
if properties.get( 'episode' ):
vidtag.setEpisode( properties.get( 'episode' ) )
if properties.get( 'season' ):
vidtag.setSeason( properties.get( 'season' ) )
if properties.get( 'plot' ):
vidtag.setPlot( properties.get( 'plot' ) )
if properties.get( 'title' ):
vidtag.setTitle( properties.get( 'title' ) )
if properties.get( 'studio' ):
vidtag.setStudios([ properties.get( 'studio' ) ])
if properties.get( 'writer' ):
vidtag.setWriters([ properties.get( 'writer' ) ])
if properties.get( 'duration' ):
vidtag.setDuration( int( properties.get( 'duration' ) ) )
if properties.get( 'tvshowtitle' ):
vidtag.setTvShowTitle( properties.get( 'tvshowtitle' ) )
if properties.get( 'mediatype' ):
vidtag.setMediaType( properties.get( 'mediatype' ) )
if properties.get('premiered'):
vidtag.setPremiered( properties.get( 'premiered' ) )
else:
line_item.setInfo('video', properties)

@ -302,6 +302,7 @@ def dir_list_create( data, cat, video_type='video', search = False, play=0 ):
for video in videos:
video_title = ''
info_labels = {}
title = re.compile(r'<h3(?:[^\>]+)?>(.*)</h3>', re.DOTALL|re.IGNORECASE).findall(video)
link = re.compile(r'<a\sclass="videostream__link link"\sdraggable="false"\shref="([^\"]+)">', re.DOTALL|re.IGNORECASE).findall(video)
@ -327,8 +328,13 @@ def dir_list_create( data, cat, video_type='video', search = False, play=0 ):
images = { 'thumb': str(img[0]), 'fanart': str(img[0]) }
duration = re.compile(r'videostream__status--duration\"\s*>([^<]+)</div>', re.DOTALL|re.IGNORECASE).findall(video)
if duration:
info_labels[ 'duration' ] = duration_to_secs( duration[0].strip() )
#open get url and open player
add_dir( video_title, BASE_URL + link[0], 4, images, {}, cat, False, True, play, { 'name' : channel_link[0], 'subscribe': True } )
add_dir( video_title, BASE_URL + link[0], 4, images, info_labels, cat, False, True, play, { 'name' : channel_link[0], 'subscribe': True } )
return amount
@ -719,13 +725,12 @@ def add_dir( name, url, mode, images = {}, info_labels = {}, cat = '', folder=Tr
list_item.setProperty('IsPlayable', 'true')
context_menu.append((get_string(30158), 'Action(Queue)'))
if KODI_VERSION > 19.8:
vidtag = list_item.getVideoInfoTag()
vidtag.setMediaType('video')
vidtag.setTitle(name)
vidtag.setPlot( info_labels.get( 'plot', '' ) )
else:
list_item.setInfo(type='Video', infoLabels={'Title': name, 'Plot': info_labels.get( 'plot', '' ) })
info_labels['title'] = name
if play:
# adds information context menu
info_labels['mediatype'] = 'tvshow'
item_set_info( list_item, info_labels )
list_item.setProperty( 'fanart_image', art_dict[ 'fanart' ] )

Loading…
Cancel
Save