2020-03-19 16:45:31 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
""" Menu module """
|
|
|
|
|
|
|
|
from __future__ import absolute_import, division, unicode_literals
|
|
|
|
|
2021-03-22 13:40:26 +01:00
|
|
|
import logging
|
|
|
|
|
2020-03-19 16:45:31 +01:00
|
|
|
from resources.lib import kodiutils
|
|
|
|
from resources.lib.kodiutils import TitleItem
|
2021-02-01 08:53:13 +01:00
|
|
|
from resources.lib.viervijfzes import STREAM_DICT
|
2020-10-26 10:25:57 +01:00
|
|
|
from resources.lib.viervijfzes.content import Episode, Program
|
2020-03-19 16:45:31 +01:00
|
|
|
|
2021-02-17 07:42:24 +01:00
|
|
|
try: # Python 3
|
|
|
|
from urllib.parse import quote
|
|
|
|
except ImportError: # Python 2
|
|
|
|
from urllib import quote
|
|
|
|
|
2021-03-22 13:40:26 +01:00
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
class Menu:
|
|
|
|
""" Menu code """
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
""" Initialise object """
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def show_mainmenu():
|
|
|
|
""" Show the main menu """
|
|
|
|
listing = [
|
2020-03-20 13:53:21 +01:00
|
|
|
TitleItem(
|
|
|
|
title=kodiutils.localize(30001), # A-Z
|
|
|
|
path=kodiutils.url_for('show_catalog'),
|
|
|
|
art_dict=dict(
|
|
|
|
icon='DefaultMovieTitle.png',
|
|
|
|
fanart=kodiutils.get_addon_info('fanart'),
|
|
|
|
),
|
|
|
|
info_dict=dict(
|
|
|
|
plot=kodiutils.localize(30002),
|
|
|
|
)
|
|
|
|
),
|
|
|
|
TitleItem(
|
|
|
|
title=kodiutils.localize(30007), # TV Channels
|
|
|
|
path=kodiutils.url_for('show_channels'),
|
|
|
|
art_dict=dict(
|
|
|
|
icon='DefaultAddonPVRClient.png',
|
|
|
|
fanart=kodiutils.get_addon_info('fanart'),
|
|
|
|
),
|
|
|
|
info_dict=dict(
|
|
|
|
plot=kodiutils.localize(30008),
|
|
|
|
)
|
|
|
|
),
|
2021-02-17 07:42:24 +01:00
|
|
|
TitleItem(
|
|
|
|
title=kodiutils.localize(30003), # Catalog
|
|
|
|
path=kodiutils.url_for('show_categories'),
|
|
|
|
art_dict=dict(
|
|
|
|
icon='DefaultGenre.png',
|
|
|
|
fanart=kodiutils.get_addon_info('fanart'),
|
|
|
|
),
|
|
|
|
info_dict=dict(
|
|
|
|
plot=kodiutils.localize(30004),
|
|
|
|
)
|
|
|
|
),
|
|
|
|
TitleItem(
|
|
|
|
title=kodiutils.localize(30005), # Recommendations
|
|
|
|
path=kodiutils.url_for('show_recommendations'),
|
|
|
|
art_dict=dict(
|
|
|
|
icon='DefaultFavourites.png',
|
|
|
|
fanart=kodiutils.get_addon_info('fanart'),
|
|
|
|
),
|
|
|
|
info_dict=dict(
|
|
|
|
plot=kodiutils.localize(30006),
|
|
|
|
)
|
|
|
|
),
|
2021-02-09 20:54:40 +01:00
|
|
|
TitleItem(
|
|
|
|
title=kodiutils.localize(30011), # My List
|
|
|
|
path=kodiutils.url_for('show_mylist'),
|
|
|
|
art_dict=dict(
|
|
|
|
icon='DefaultPlaylist.png',
|
|
|
|
fanart=kodiutils.get_addon_info('fanart'),
|
|
|
|
),
|
|
|
|
info_dict=dict(
|
|
|
|
plot=kodiutils.localize(30012),
|
|
|
|
)
|
|
|
|
),
|
2020-03-20 13:53:21 +01:00
|
|
|
TitleItem(
|
|
|
|
title=kodiutils.localize(30009), # Search
|
|
|
|
path=kodiutils.url_for('show_search'),
|
|
|
|
art_dict=dict(
|
|
|
|
icon='DefaultAddonsSearch.png',
|
|
|
|
fanart=kodiutils.get_addon_info('fanart'),
|
|
|
|
),
|
|
|
|
info_dict=dict(
|
|
|
|
plot=kodiutils.localize(30010),
|
|
|
|
)
|
|
|
|
)
|
2020-03-19 16:45:31 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
kodiutils.show_listing(listing, sort=['unsorted'])
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def generate_titleitem(item):
|
|
|
|
""" Generate a TitleItem based on a Program or Episode.
|
|
|
|
:type item: Union[Program, Episode]
|
|
|
|
:rtype TitleItem
|
|
|
|
"""
|
|
|
|
info_dict = {
|
|
|
|
'title': item.title,
|
|
|
|
'plot': item.description,
|
|
|
|
'aired': item.aired.strftime('%Y-%m-%d') if item.aired else None,
|
|
|
|
}
|
|
|
|
prop_dict = {}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Program
|
|
|
|
#
|
|
|
|
if isinstance(item, Program):
|
|
|
|
info_dict.update({
|
|
|
|
'mediatype': None,
|
|
|
|
'season': len(item.seasons) if item.seasons else None,
|
|
|
|
})
|
|
|
|
|
2021-03-19 16:45:26 +01:00
|
|
|
art_dict = {
|
|
|
|
'poster': item.poster,
|
|
|
|
'landscape': item.thumb,
|
|
|
|
'thumb': item.thumb,
|
|
|
|
'fanart': item.fanart,
|
|
|
|
}
|
|
|
|
|
2021-02-17 07:42:24 +01:00
|
|
|
visible = True
|
2021-09-15 16:18:53 +02:00
|
|
|
title = item.title
|
2020-03-22 15:37:15 +01:00
|
|
|
|
2021-02-09 20:54:40 +01:00
|
|
|
context_menu = []
|
|
|
|
if item.uuid:
|
|
|
|
if item.my_list:
|
|
|
|
context_menu.append((
|
|
|
|
kodiutils.localize(30101), # Remove from My List
|
|
|
|
'Container.Update(%s)' %
|
|
|
|
kodiutils.url_for('mylist_del', uuid=item.uuid)
|
|
|
|
))
|
|
|
|
else:
|
|
|
|
context_menu.append((
|
|
|
|
kodiutils.localize(30100), # Add to My List
|
|
|
|
'Container.Update(%s)' %
|
|
|
|
kodiutils.url_for('mylist_add', uuid=item.uuid)
|
|
|
|
))
|
|
|
|
|
|
|
|
context_menu.append((
|
|
|
|
kodiutils.localize(30102), # Go to Program
|
|
|
|
'Container.Update(%s)' %
|
|
|
|
kodiutils.url_for('show_catalog_program', program=item.path)
|
|
|
|
))
|
|
|
|
|
2020-03-22 15:37:15 +01:00
|
|
|
return TitleItem(title=title,
|
2021-02-01 13:44:39 +01:00
|
|
|
path=kodiutils.url_for('show_catalog_program', program=item.path),
|
2021-02-09 20:54:40 +01:00
|
|
|
context_menu=context_menu,
|
2020-03-19 16:45:31 +01:00
|
|
|
art_dict=art_dict,
|
2021-02-17 07:42:24 +01:00
|
|
|
info_dict=info_dict,
|
|
|
|
visible=visible)
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Episode
|
|
|
|
#
|
|
|
|
if isinstance(item, Episode):
|
|
|
|
info_dict.update({
|
|
|
|
'mediatype': 'episode',
|
|
|
|
'tvshowtitle': item.program_title,
|
|
|
|
'duration': item.duration,
|
|
|
|
'season': item.season,
|
|
|
|
'episode': item.number,
|
|
|
|
})
|
|
|
|
|
2021-03-19 16:45:26 +01:00
|
|
|
art_dict = {
|
|
|
|
'landscape': item.thumb,
|
|
|
|
'thumb': item.thumb,
|
|
|
|
'fanart': item.thumb,
|
|
|
|
}
|
|
|
|
|
2020-03-22 10:39:49 +01:00
|
|
|
stream_dict = STREAM_DICT.copy()
|
|
|
|
stream_dict.update({
|
2020-03-19 16:45:31 +01:00
|
|
|
'duration': item.duration,
|
2020-03-22 10:39:49 +01:00
|
|
|
})
|
2020-03-19 16:45:31 +01:00
|
|
|
|
2021-03-22 13:40:26 +01:00
|
|
|
if item.uuid:
|
2020-04-20 08:59:10 +02:00
|
|
|
# We have an UUID and can play this item directly
|
2020-05-25 20:41:38 +02:00
|
|
|
path = kodiutils.url_for('play_catalog', uuid=item.uuid)
|
2021-03-22 13:40:26 +01:00
|
|
|
else:
|
|
|
|
# We don't have an UUID, and first need to fetch the video information from the page
|
|
|
|
path = kodiutils.url_for('play_from_page', page=quote(item.path, safe=''))
|
2020-04-20 08:59:10 +02:00
|
|
|
|
2020-03-19 16:45:31 +01:00
|
|
|
return TitleItem(title=info_dict['title'],
|
2020-04-20 08:59:10 +02:00
|
|
|
path=path,
|
2020-03-19 16:45:31 +01:00
|
|
|
art_dict=art_dict,
|
|
|
|
info_dict=info_dict,
|
|
|
|
stream_dict=stream_dict,
|
|
|
|
prop_dict=prop_dict,
|
|
|
|
is_playable=True)
|
|
|
|
|
|
|
|
raise Exception('Unknown video_type')
|