2020-03-19 16:45:31 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
""" Addon code """
|
|
|
|
|
|
|
|
from __future__ import absolute_import, division, unicode_literals
|
|
|
|
|
2020-03-22 15:37:15 +01:00
|
|
|
import logging
|
|
|
|
|
2020-03-19 16:45:31 +01:00
|
|
|
from routing import Plugin
|
|
|
|
|
|
|
|
from resources.lib import kodilogging
|
|
|
|
|
2020-03-25 08:08:15 +01:00
|
|
|
routing = Plugin() # pylint: disable=invalid-name
|
2020-10-26 10:25:57 +01:00
|
|
|
_LOGGER = logging.getLogger(__name__)
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
@routing.route('/')
|
|
|
|
def show_main_menu():
|
|
|
|
""" Show the main menu """
|
|
|
|
from resources.lib.modules.menu import Menu
|
|
|
|
Menu().show_mainmenu()
|
|
|
|
|
|
|
|
|
|
|
|
@routing.route('/channels')
|
|
|
|
def show_channels():
|
|
|
|
""" Shows Live TV channels """
|
|
|
|
from resources.lib.modules.channels import Channels
|
|
|
|
Channels().show_channels()
|
|
|
|
|
|
|
|
|
|
|
|
@routing.route('/channels/<channel>')
|
|
|
|
def show_channel_menu(channel):
|
|
|
|
""" Shows Live TV channels """
|
|
|
|
from resources.lib.modules.channels import Channels
|
|
|
|
Channels().show_channel_menu(channel)
|
|
|
|
|
|
|
|
|
2021-02-01 08:53:13 +01:00
|
|
|
# @routing.route('/channels/<channel>/categories')
|
|
|
|
# def show_channel_categories(channel):
|
|
|
|
# """ Shows TV Channel categories """
|
|
|
|
# from resources.lib.modules.channels import Channels
|
|
|
|
# Channels().show_channel_categories(channel)
|
2020-04-20 08:59:10 +02:00
|
|
|
|
|
|
|
|
2021-02-01 08:53:13 +01:00
|
|
|
# @routing.route('/channels/<channel>/categories/<category>')
|
|
|
|
# def show_channel_category(channel, category):
|
|
|
|
# """ Shows TV Channel categories """
|
|
|
|
# from resources.lib.modules.channels import Channels
|
|
|
|
# Channels().show_channel_category(channel, category)
|
2020-04-20 08:59:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
@routing.route('/channels/<channel>/tvguide')
|
|
|
|
def show_channel_tvguide(channel):
|
2020-03-19 16:45:31 +01:00
|
|
|
""" Shows the dates in the tv guide """
|
|
|
|
from resources.lib.modules.tvguide import TvGuide
|
2020-04-20 08:59:10 +02:00
|
|
|
TvGuide().show_channel(channel)
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
|
2020-04-20 08:59:10 +02:00
|
|
|
@routing.route('/channels/<channel>/tvguide/<date>')
|
|
|
|
def show_channel_tvguide_detail(channel=None, date=None):
|
2020-03-19 16:45:31 +01:00
|
|
|
""" Shows the programs of a specific date in the tv guide """
|
|
|
|
from resources.lib.modules.tvguide import TvGuide
|
2020-04-20 08:59:10 +02:00
|
|
|
TvGuide().show_detail(channel, date)
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
|
2021-02-01 08:53:13 +01:00
|
|
|
@routing.route('/channels/<channel>/catalog')
|
|
|
|
def show_channel_catalog(channel):
|
|
|
|
""" Show the catalog of a channel """
|
|
|
|
from resources.lib.modules.catalog import Catalog
|
|
|
|
Catalog().show_catalog_channel(channel)
|
|
|
|
|
|
|
|
|
2020-03-19 16:45:31 +01:00
|
|
|
@routing.route('/catalog')
|
|
|
|
def show_catalog():
|
|
|
|
""" Show the catalog """
|
|
|
|
from resources.lib.modules.catalog import Catalog
|
|
|
|
Catalog().show_catalog()
|
|
|
|
|
|
|
|
|
2021-02-01 08:53:13 +01:00
|
|
|
@routing.route('/catalog/<program>')
|
|
|
|
def show_catalog_program(program):
|
2020-03-19 16:45:31 +01:00
|
|
|
""" Show a program from the catalog """
|
|
|
|
from resources.lib.modules.catalog import Catalog
|
2021-02-01 08:53:13 +01:00
|
|
|
Catalog().show_program(program)
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
|
2021-02-01 08:53:13 +01:00
|
|
|
@routing.route('/catalog/<program>/clips')
|
|
|
|
def show_catalog_program_clips(program):
|
2020-04-20 08:59:10 +02:00
|
|
|
""" Show the clips from a program """
|
|
|
|
from resources.lib.modules.catalog import Catalog
|
2021-02-01 08:53:13 +01:00
|
|
|
Catalog().show_program_clips(program)
|
2020-04-20 08:59:10 +02:00
|
|
|
|
|
|
|
|
2021-02-01 08:53:13 +01:00
|
|
|
@routing.route('/catalog/<program>/season/<season>')
|
|
|
|
def show_catalog_program_season(program, season):
|
2020-04-20 08:59:10 +02:00
|
|
|
""" Show a season from a program """
|
2020-03-19 16:45:31 +01:00
|
|
|
from resources.lib.modules.catalog import Catalog
|
2021-02-01 08:53:13 +01:00
|
|
|
Catalog().show_program_season(program, season)
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
|
2021-02-09 20:54:40 +01:00
|
|
|
@routing.route('/mylist')
|
|
|
|
def show_mylist():
|
|
|
|
""" Show my list """
|
|
|
|
from resources.lib.modules.catalog import Catalog
|
|
|
|
Catalog().show_mylist()
|
|
|
|
|
|
|
|
|
|
|
|
@routing.route('/mylist/add/<uuid>')
|
|
|
|
def mylist_add(uuid):
|
|
|
|
""" Add a program to My List """
|
|
|
|
from resources.lib.modules.catalog import Catalog
|
|
|
|
Catalog().mylist_add(uuid)
|
|
|
|
|
|
|
|
|
|
|
|
@routing.route('/mylist/del/<uuid>')
|
|
|
|
def mylist_del(uuid):
|
|
|
|
""" Remove a program from My List """
|
|
|
|
from resources.lib.modules.catalog import Catalog
|
|
|
|
Catalog().mylist_del(uuid)
|
|
|
|
|
|
|
|
|
2020-03-19 16:45:31 +01:00
|
|
|
@routing.route('/search')
|
|
|
|
@routing.route('/search/<query>')
|
|
|
|
def show_search(query=None):
|
|
|
|
""" Shows the search dialog """
|
|
|
|
from resources.lib.modules.search import Search
|
|
|
|
Search().show_search(query)
|
|
|
|
|
|
|
|
|
2020-05-25 20:41:38 +02:00
|
|
|
@routing.route('/play/live/<channel>')
|
|
|
|
def play_live(channel):
|
|
|
|
""" Play the requested item """
|
|
|
|
from resources.lib.modules.player import Player
|
|
|
|
Player().live(channel)
|
|
|
|
|
|
|
|
|
|
|
|
@routing.route('/play/epg/<channel>/<timestamp>')
|
|
|
|
def play_epg(channel, timestamp):
|
|
|
|
""" Play the requested item """
|
|
|
|
from resources.lib.modules.tvguide import TvGuide
|
|
|
|
TvGuide().play_epg_datetime(channel, timestamp)
|
|
|
|
|
|
|
|
|
2020-03-22 15:37:15 +01:00
|
|
|
@routing.route('/play/catalog/<uuid>')
|
2020-05-25 20:41:38 +02:00
|
|
|
def play_catalog(uuid):
|
2020-03-19 16:45:31 +01:00
|
|
|
""" Play the requested item """
|
|
|
|
from resources.lib.modules.player import Player
|
2020-03-22 15:37:15 +01:00
|
|
|
Player().play(uuid)
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
|
2021-02-01 08:53:13 +01:00
|
|
|
@routing.route('/play/page/<page>')
|
|
|
|
def play_from_page(page):
|
2020-03-19 16:45:31 +01:00
|
|
|
""" Play the requested item """
|
|
|
|
try: # Python 3
|
|
|
|
from urllib.parse import unquote
|
|
|
|
except ImportError: # Python 2
|
|
|
|
from urllib import unquote
|
|
|
|
|
|
|
|
from resources.lib.modules.player import Player
|
2021-02-01 08:53:13 +01:00
|
|
|
Player().play_from_page(unquote(page))
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
|
2020-03-22 15:37:15 +01:00
|
|
|
@routing.route('/metadata/update')
|
|
|
|
def metadata_update():
|
|
|
|
""" Update the metadata for the listings (called from settings) """
|
|
|
|
from resources.lib.modules.metadata import Metadata
|
|
|
|
Metadata().update()
|
|
|
|
|
|
|
|
|
2020-06-19 15:20:20 +02:00
|
|
|
@routing.route('/metadata/clean')
|
|
|
|
def metadata_clean():
|
|
|
|
""" Clear the metadata for the listings (called from settings) """
|
|
|
|
from resources.lib.modules.metadata import Metadata
|
|
|
|
Metadata().clean()
|
|
|
|
|
|
|
|
|
2020-05-25 20:41:38 +02:00
|
|
|
@routing.route('/iptv/channels')
|
|
|
|
def iptv_channels():
|
|
|
|
""" Generate channel data for the Kodi PVR integration """
|
|
|
|
from resources.lib.modules.iptvmanager import IPTVManager
|
|
|
|
IPTVManager(int(routing.args['port'][0])).send_channels() # pylint: disable=too-many-function-args
|
|
|
|
|
|
|
|
|
|
|
|
@routing.route('/iptv/epg')
|
|
|
|
def iptv_epg():
|
|
|
|
""" Generate EPG data for the Kodi PVR integration """
|
|
|
|
from resources.lib.modules.iptvmanager import IPTVManager
|
|
|
|
IPTVManager(int(routing.args['port'][0])).send_epg() # pylint: disable=too-many-function-args
|
|
|
|
|
|
|
|
|
2020-03-19 16:45:31 +01:00
|
|
|
def run(params):
|
|
|
|
""" Run the routing plugin """
|
2021-02-09 21:09:58 +01:00
|
|
|
kodilogging.config()
|
2020-03-19 16:45:31 +01:00
|
|
|
routing.run(params)
|