Skip to content

Commit

Permalink
Movie and TV Series integration into the Kodi library
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelarnauts committed Oct 6, 2020
1 parent 6b0b47e commit 7a4a4b7
Show file tree
Hide file tree
Showing 12 changed files with 454 additions and 37 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,35 @@ De volgende features worden ondersteund:
* Afspelen van films en series
* Volledig overzicht van alle content
* Zoeken in de volledige catalogus
* Integratie met Kodi bibliotheek

## Integratie met Kodi

Je kan deze Add-on gebruiken als medialocatie in Kodi zodat de films en series ook in je Kodi bibliotheek geindexeerd staan. Ze worden uiteraard nog steeds
gewoon gestreamed.

Ga hiervoor naar **Instellingen** > **Media** > **Bibliotheek** > **Video's...** (bij bronnen beheren). Kies vervolgens **Toevoegen video's...** en geef
onderstaande locatie in door **< Geen >** te kiezen. Geef vervolgens de naam op en kies OK. Stel daarna de opties in zoals hieronder opgegeven en bevestig met OK.
Stem daarna toe om deze locaties te scannen.

* Films:
* Locatie: `plugin://plugin.video.streamz/library/movies/`
* Naam: **Streamz - Films**
* Opties:
* Deze map bevat: **Speelfilms**
* Kies informatieleverancier: **Local information only**
* Films staan in aparte folders die overeenkomen met de filmtitel: **Uit**
* Ook onderliggende mappen scannen : **Uit**
* Locatie uitsluiten van bibliotheekupdates: **Uit**

* Series:
* Locatie: `plugin://plugin.video.streamz/library/tvshows/`
* Naam: **Streamz - Series**
* Opties:
* Deze map bevat: **Series**
* Kies informatieleverancier: **Local information only**
* Geselecteerde map bevat één enkele serie: **Uit**
* Locatie uitsluiten van bibliotheekupdates: **Uit**

## Screenshots

Expand Down
4 changes: 3 additions & 1 deletion addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
</requires>
<extension point="xbmc.python.pluginsource" library="addon_entry.py">
<provides>video</provides>
<medialibraryscanpath content="movies">library/movies/</medialibraryscanpath>
<medialibraryscanpath content="tvshows">library/tvshows/</medialibraryscanpath>
</extension>
<extension point="xbmc.service" library="service_entry.py"/>
<extension point="xbmc.addon.metadata">
Expand All @@ -22,7 +24,7 @@
<description lang="nl_NL">Streamz is een video-on-demand platform dat toegang biedt tot Vlaamse series en films van DPG Media, Telenet en VRT, maar ook films en series van 'Home of HBO' en de laatste blockbuster films.</description>
<disclaimer lang="nl_NL">Deze add-on wordt niet ondersteund door Streamz BV, en wordt aangeboden 'as is', zonder enige garantie. De Streamz naam en Streamz logo zijn eigendom van Streamz BV en worden gebruikt in overeenstemming met de 'fair use' regels.</disclaimer>
<platform>all</platform>
<license>GPL-3.0</license>
<license>GPL-3.0-only</license>
<news>v0.0.1 (2020-09-21)
- Initial release</news>
<source>https://github.com/add-ons/plugin.video.streamz</source>
Expand Down
41 changes: 40 additions & 1 deletion resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ msgctxt "#30716"
msgid "Updating metadata ({index}/{total})..."
msgstr ""


### SETTINGS
msgctxt "#30800"
msgid "Credentials"
Expand Down Expand Up @@ -295,6 +294,46 @@ msgctxt "#30864"
msgid "Up Next settings…"
msgstr ""

msgctxt "#30870"
msgid "Kodi Library"
msgstr ""

msgctxt "#30871"
msgid "Indexing"
msgstr ""

msgctxt "#30872"
msgid "Add video locations to the Kodi Library… [COLOR gray](See README.md)[/COLOR]"
msgstr ""

msgctxt "#30873"
msgid "Index the following movies"
msgstr ""

msgctxt "#30874"
msgid "Index the following series"
msgstr ""

msgctxt "#30875"
msgid "Full catalog"
msgstr ""

msgctxt "#30876"
msgid "Items on 'My List' only"
msgstr ""

msgctxt "#30877"
msgid "Maintenance"
msgstr ""

msgctxt "#30878"
msgid "Refresh Library…"
msgstr ""

msgctxt "#30879"
msgid "Clean Library…"
msgstr ""

msgctxt "#30880"
msgid "Expert"
msgstr ""
Expand Down
40 changes: 40 additions & 0 deletions resources/language/resource.language.nl_nl/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,46 @@ msgctxt "#30864"
msgid "Up Next settings…"
msgstr "Up Next instellingen…"

msgctxt "#30870"
msgid "Kodi Library"
msgstr "Kodi-bibliotheek"

msgctxt "#30871"
msgid "Indexing"
msgstr "Indexeren"

msgctxt "#30872"
msgid "Add video locations to the Kodi Library… [COLOR gray](See README.md)[/COLOR]"
msgstr "Videolocaties toevoegen aan de Kodi-bibliotheek… [COLOR gray](Zie README.md)[/COLOR]"

msgctxt "#30873"
msgid "Index the following movies"
msgstr "Indexeer de volgende films"

msgctxt "#30874"
msgid "Index the following series"
msgstr "Indexeer de volgende series"

msgctxt "#30875"
msgid "Full catalog"
msgstr "Volledige catalogus"

msgctxt "#30876"
msgid "Items on 'My List' only"
msgstr "Enkel items op 'Mijn lijst'"

msgctxt "#30877"
msgid "Maintenance"
msgstr "Onderhoud"

msgctxt "#30878"
msgid "Refresh Library…"
msgstr "Verniew bibliotheek…"

msgctxt "#30879"
msgid "Clean Library…"
msgstr "Bibliotheek opkuisen…"

msgctxt "#30880"
msgid "Expert"
msgstr "Expert"
Expand Down
64 changes: 62 additions & 2 deletions resources/lib/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from requests import HTTPError

from resources.lib import kodilogging, kodiutils
from resources.lib.streamz.exceptions import NoLoginException, InvalidLoginException, LoginErrorException, NoTelenetSubscriptionException, \
NoStreamzSubscriptionException
from resources.lib.streamz.exceptions import (NoLoginException, InvalidLoginException, LoginErrorException, NoTelenetSubscriptionException,
NoStreamzSubscriptionException)

kodilogging.config()
routing = routing.Plugin() # pylint: disable=invalid-name
Expand Down Expand Up @@ -109,6 +109,66 @@ def show_catalog_program_season(program, season):
Catalog().show_program_season(program, int(season))


@routing.route('/library/movies/')
def library_movies():
""" Show a list of all movies for integration into the Kodi Library """
from resources.lib.modules.library import Library

# Library seems to have issues with folder mode
movie = routing.args.get('movie', [])[0] if routing.args.get('movie') else None

if 'check_exists' in routing.args.get('kodi_action', []):
Library().check_library_movie(movie)
return

if movie:
play('movies', movie)
else:
Library().show_library_movies()


@routing.route('/library/tvshows/')
def library_tvshows():
""" Show a list of all tv series for integration into the Kodi Library """
from resources.lib.modules.library import Library

# Library seems to have issues with folder mode
program = routing.args.get('program', [])[0] if routing.args.get('program') else None
episode = routing.args.get('episode', [])[0] if routing.args.get('episode') else None

if 'check_exists' in routing.args.get('kodi_action', []):
Library().check_library_tvshow(program)
return

if episode:
play('episodes', episode)
elif program:
Library().show_library_tvshows_program(program)
else:
Library().show_library_tvshows()


@routing.route('/library/configure')
def library_configure():
""" Show information on how to enable the library integration """
from resources.lib.modules.library import Library
Library().configure()


@routing.route('/library/update')
def library_update():
""" Refresh the library. """
from resources.lib.modules.library import Library
Library().update()


@routing.route('/library/clean')
def library_clean():
""" Clean the library. """
from resources.lib.modules.library import Library
Library().clean()


@routing.route('/catalog/recommendations/<storefront>')
def show_recommendations(storefront):
""" Shows the programs of a specific date in the tv guide """
Expand Down
54 changes: 47 additions & 7 deletions resources/lib/kodiutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ def play(stream, license_key=None, title=None, art_dict=None, info_dict=None, pr
xbmcplugin.setResolvedUrl(routing.handle, True, listitem=play_item)


def library_return_status(success):
"""Notify Kodi about the status of a listitem."""
from resources.lib.addon import routing

_LOGGER.debug('Returning status %s', success)
xbmcplugin.setResolvedUrl(routing.handle, success, listitem=xbmcgui.ListItem())


def get_search_string(heading='', message=''):
"""Ask the user for a search string"""
search_string = None
Expand All @@ -241,6 +249,14 @@ def ok_dialog(heading='', message=''):
return Dialog().ok(heading=heading, message=message)


def textviewer(heading='', text='', usemono=False):
"""Show Kodi's textviewer dialog"""
from xbmcgui import Dialog
if not heading:
heading = addon_name()
Dialog().textviewer(heading=heading, text=text, usemono=usemono)


def show_context_menu(items):
"""Show Kodi's OK dialog"""
from xbmcgui import Dialog
Expand Down Expand Up @@ -475,6 +491,11 @@ def get_addon_info(key):
return to_unicode(ADDON.getAddonInfo(key))


def execute_builtin(function):
""" Execute a Kodi Builtin """
xbmc.executebuiltin(function)


def container_refresh(url=None):
"""Refresh the current container or (re)load a container by URL"""
if url:
Expand Down Expand Up @@ -553,7 +574,6 @@ def get_cache(key, ttl=None):
import time

fullpath = os.path.join(get_cache_path(), '.'.join(key))

if not xbmcvfs.exists(fullpath):
return None

Expand All @@ -574,12 +594,18 @@ def get_cache(key, ttl=None):
def set_cache(key, data):
""" Store an item in the cache
:type key: list[str]
:type data: str
:type data: str|None
"""
if not xbmcvfs.exists(get_cache_path()):
xbmcvfs.mkdirs(get_cache_path())
fullpath = get_cache_path() + '/'
if not xbmcvfs.exists(fullpath):
xbmcvfs.mkdirs(fullpath)

fullpath = os.path.join(get_cache_path(), '.'.join(key))
fullpath = os.path.join(fullpath, '.'.join(key))

if data is None:
# Remove from cache
xbmcvfs.delete(fullpath)
return

fdesc = xbmcvfs.File(fullpath, 'w')

Expand All @@ -592,8 +618,7 @@ def set_cache(key, data):

def invalidate_cache(ttl=None):
""" Clear the cache """
fullpath = get_cache_path()

fullpath = get_cache_path() + '/'
if not xbmcvfs.exists(fullpath):
return

Expand All @@ -607,6 +632,21 @@ def invalidate_cache(ttl=None):
xbmcvfs.delete(filepath)


def cleanup_cache(category, keep):
""" Clear the cache by removing missing items. """
fullpath = get_cache_path() + '/'

if not xbmcvfs.exists(fullpath):
return

_, files = xbmcvfs.listdir(fullpath)
for filename in files:
cat, uuid = filename.split('.')
if cat == category and uuid not in keep:
_LOGGER.debug('Removing %s from cache since it is missing in the full listing', filename)
xbmcvfs.delete(os.path.join(fullpath, filename))


def notify(sender, message, data):
""" Send a notification to Kodi using JSON RPC """
result = jsonrpc(method='JSONRPC.NotifyAll', params=dict(
Expand Down
Loading

0 comments on commit 7a4a4b7

Please sign in to comment.