Skip to content

Commit

Permalink
Integrate Movies and TV Series into the Kodi library (#9)
Browse files Browse the repository at this point in the history
* Movie and TV Series integration into the Kodi library
* Automatically update library when adding/removing from My List
  • Loading branch information
michaelarnauts authored Nov 3, 2020
1 parent 31b1777 commit bd3fe6f
Show file tree
Hide file tree
Showing 14 changed files with 511 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
2 changes: 2 additions & 0 deletions 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 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 @@ -185,7 +185,6 @@ msgctxt "#30716"
msgid "Updating metadata ({index}/{total})..."
msgstr ""


### SETTINGS
msgctxt "#30800"
msgid "Credentials"
Expand Down Expand Up @@ -303,6 +302,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 @@ -304,6 +304,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
74 changes: 74 additions & 0 deletions resources/lib/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,74 @@ 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 'refresh_info' in routing.args.get('kodi_action', []):
Library().show_library_movies(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 'refresh_info' in routing.args.get('kodi_action', []):
Library().show_library_tvshows(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 recommendations of a storefront """
Expand Down Expand Up @@ -107,13 +175,19 @@ def mylist_add(video_type, content_id):
from resources.lib.modules.catalog import Catalog
Catalog().mylist_add(video_type, content_id)

from resources.lib.modules.library import Library
Library().mylist_added(video_type, content_id)


@routing.route('/catalog/mylist/del/<video_type>/<content_id>')
def mylist_del(video_type, content_id):
""" Remove an item from "My List" """
from resources.lib.modules.catalog import Catalog
Catalog().mylist_del(video_type, content_id)

from resources.lib.modules.library import Library
Library().mylist_removed(video_type, content_id)


@routing.route('/catalog/continuewatching')
def show_continuewatching():
Expand Down
34 changes: 27 additions & 7 deletions resources/lib/kodiutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,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 @@ -245,6 +253,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 @@ -562,7 +578,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 @@ -584,12 +599,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: any
"""
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 @@ -602,8 +623,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 Down
5 changes: 2 additions & 3 deletions resources/lib/modules/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def show_recommendations_category(self, storefront, category):
listing.append(Menu.generate_titleitem(item))

# Sort categories by default like in Streamz.
kodiutils.show_listing(listing, 30015, content='tvshows')
kodiutils.show_listing(listing, 30015, content='tvshows', sort=['unsorted', 'label', 'year', 'duration'])

def show_mylist(self):
""" Show the items in "My List". """
Expand All @@ -196,7 +196,7 @@ def show_mylist(self):
listing.append(Menu.generate_titleitem(item))

# Sort categories by default like in Streamz.
kodiutils.show_listing(listing, 30017, content='tvshows')
kodiutils.show_listing(listing, 30017, content='tvshows', sort=['unsorted', 'label', 'year', 'duration'])

def mylist_add(self, video_type, content_id):
""" Add an item to "My List".
Expand All @@ -215,7 +215,6 @@ def mylist_del(self, video_type, content_id):
"""
self._api.del_mylist(video_type, content_id)
kodiutils.end_of_directory()
kodiutils.container_refresh()

def show_continuewatching(self):
""" Show the items in "Continue Watching". """
Expand Down
Loading

0 comments on commit bd3fe6f

Please sign in to comment.