Skip to content

Commit

Permalink
[plugin.video.cinetree] v.1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkroon authored May 29, 2024
1 parent 64ea953 commit ccc6623
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 31 deletions.
9 changes: 3 additions & 6 deletions plugin.video.cinetree/addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.cinetree" name="Cinetree" version="1.2.0" provider-name="Dimitri Kroon">
<addon id="plugin.video.cinetree" name="Cinetree" version="1.2.1" provider-name="Dimitri Kroon">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="inputstream.adaptive" version="19.0.5"/>
Expand Down Expand Up @@ -37,11 +37,8 @@
</assets>
<reuselanguageinvoker>true</reuselanguageinvoker>
<news>
- Fix: Some folders failed to open with parse error.
- Added support for all available subtitles in various languages.
- Info like plot and cast is now available while the video plays.
- Fix: Kodi-20 freezes for a long time after an error in the add-on.
- Increased timeout for web requests.
- Fix: Listings of subscription films failed with error Not Found.
- Some other minor issues.
</news>
</extension>
</addon>
4 changes: 4 additions & 0 deletions plugin.video.cinetree/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v.1.2.1
- Fix: Listings of subscription films failed with error Not Found.
- Some other minor issues.

v.1.2.0
- Fix: Some folders fail to open with parse error.
- Added support for all available subtitles in various languages.
Expand Down
19 changes: 18 additions & 1 deletion plugin.video.cinetree/resources/lib/ctree/ct_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,23 @@ def get_jsonp(path):
return resp_dict


def get_recommended():
"""Return the uuids of the hero items on the subscription page"""
data, _ = storyblok.get_url('stories//films-en-documentaires',
params={'from_release': 'undefined', 'resolve_relations': 'menu,selectedBy'})
page_top = data['story']['content']['top']
for section in page_top:
if section['component'] == 'row-featured-films':
return section['films']
return []


def get_subscription_films():
"""Return a list of ID's of the current subscription films"""
resp = fetch.get_json('https://api.cinetree.nl/films/svod')
return resp


def create_stream_info_url(film_uuid, slug=None):
"""Return the url to the stream info (json) document.
Expand Down Expand Up @@ -140,7 +157,7 @@ def get_watched_films(finished=False):

for film in my_films:
duration = utils.duration_2_seconds(film['content'].get('duration', 0))
if duration - history[film['uuid']]['playtime'] < min(20, duration * 0.02):
if duration - history[film['uuid']]['playtime'] < max(20, duration * 0.02):
finished_films.append(film)
else:
watched_films.append(film)
Expand Down
23 changes: 5 additions & 18 deletions plugin.video.cinetree/resources/lib/ctree/ct_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ def _select_trailer_url(film_data: dict, prefer_original: bool) -> str:
YouTube as well.
There is no guarantee that fields ar present. Also string type of fields can be empty.
There is no guarantee that fields ar present. Also string type of fields can be empty, or have
leading or trailing whitespace.
If originalTrailer is present it will be a dict with fields 'plugin' and 'selected'.
Field 'selected' is a unique string, but may be None to indicate that no trailer is present.
Expand All @@ -139,8 +140,8 @@ def _select_trailer_url(film_data: dict, prefer_original: bool) -> str:
"""

vimeo_url = film_data.get('trailerVimeoURL')
orig_url = film_data.get('originalTrailerURL')
vimeo_url = film_data.get('trailerVimeoURL', '').strip()
orig_url = film_data.get('originalTrailerURL', '').strip()
orig_trailer = film_data.get('originalTrailer')

try:
Expand Down Expand Up @@ -300,21 +301,7 @@ def create_films_list(data, list_type='generic'):
if 'shorts' in content.keys():
films_list.extend(content['shorts'])
else:
# A data-dict from films-en-documentaires provides two films lists
# One list of recommended film which has only a few items, another with the full
# list of films available in the monthly subscription.
film_items = sorted((v['films'] for k, v in data['fetch'].items() if k.startswith('data-')), key=len)

if list_type == 'subscription':
films_list = film_items[1]
elif list_type == 'recommended':
# As the recommended items do not have all info we need, select the recommended films from the full list
# noinspection PyTypeChecker
recommended = tuple(film['full_slug'] for film in film_items[0])
# noinspection PyTypeChecker
films_list = (film for film in film_items[1] if film['full_slug'] in recommended)
else:
raise ValueError("Invalid value '{}' for parameter 'list_type'".format(list_type))
raise ValueError("Invalid value '{}' for parameter 'list_type'".format(list_type))
except KeyError:
raise ValueError("Invalid value of param data")

Expand Down
11 changes: 9 additions & 2 deletions plugin.video.cinetree/resources/lib/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,15 @@ def list_my_films(_, subcategory=None):

@Route.register(cache_ttl=-1, content_type='movies')
def list_films_and_docus(_, category):
resp_dict = ct_api.get_jsonp('films-en-documentaires/payload.js')
films = ct_data.create_films_list(resp_dict, category)
"""List subscription films"""
if category == 'subscription':
film_ids = ct_api.get_subscription_films()
elif category == 'recommended':
film_ids = ct_api.get_recommended()
else:
return None
stories, _ = storyblok.stories_by_uuids(film_ids)
films = ct_data.create_films_list(stories, 'storyblok')
items = [Listitem.from_dict(callback=play_film, **film) for film in films]
return items

Expand Down
8 changes: 4 additions & 4 deletions plugin.video.cinetree/resources/lib/storyblok.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def clear_cache_version():
cache_version = 'undefined'


def _get_url(path, **kwargs):
def get_url(path, **kwargs):
global cache_version

headers = {
Expand Down Expand Up @@ -88,7 +88,7 @@ def _get_url_page(path, page=None, items_per_page=None, **kwargs):

while True:
params.update({'page': cur_page, 'per_page': num_to_fetch})
data, headers = _get_url(path, **kwargs)
data, headers = get_url(path, **kwargs)
new_stories = data.get('stories')
stories.extend(new_stories)
total = int(headers.get('total', 0))
Expand All @@ -104,7 +104,7 @@ def stories_by_uuids(uuids, page=None, items_per_page=None):
"""Return the list of stories defined by the uuid in uuids.
:param uuids: A single uuid as string or an iterable of uuid's referring
to a story on Storyblok
to a stories on Storyblok
:param page: Return the items of page number *page*. If None, return all items.
:param items_per_page: Number of items to return per page.
:return: A tuple of a list of stories end the total number of available stories.
Expand Down Expand Up @@ -138,7 +138,7 @@ def story_by_name(slug: str):
'resolve_relations': 'selectedBy',
'from_release': 'undefined'
}
data, _ = _get_url(path, params=params)
data, _ = get_url(path, params=params)
return data['story']


Expand Down

0 comments on commit ccc6623

Please sign in to comment.