Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
Fix menu (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
mediaminister authored Sep 15, 2021
1 parent f221d00 commit 9c44d32
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 46 deletions.
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ disable=
too-many-statements,
use-maxsplit-arg,
consider-using-from-import,
unspecified-encoding,

super-with-arguments, # Python 2.7 compatibility
raise-missing-from, # Python 2.7 compatibility
raise-missing-from, # Python 2.7 compatibility
2 changes: 1 addition & 1 deletion resources/lib/modules/iptvmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def send_epg(): # pylint: disable=no-method-argument

today = datetime.today()

results = dict()
results = {}
for key, channel in CHANNELS.items():
iptv_id = channel.get('iptv_id')

Expand Down
9 changes: 1 addition & 8 deletions resources/lib/modules/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,7 @@ def generate_titleitem(item):
}

visible = True
if isinstance(item.episodes, list) and not item.episodes:
# We know that we don't have episodes
title = '[COLOR gray]' + item.title + '[/COLOR]'
visible = kodiutils.get_setting_bool('interface_show_unavailable')

else:
# We have episodes, or we don't know it
title = item.title
title = item.title

context_menu = []
if item.uuid:
Expand Down
75 changes: 39 additions & 36 deletions resources/lib/viervijfzes/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,30 +454,33 @@ def get_recommendation_categories(self):

# Categories regexes
regex_articles = re.compile(r'<article[^>]+>(.*?)</article>', re.DOTALL)
regex_category = re.compile(r'<h1.*?>(.*?)</h1>(?:.*?<div class="visually-hidden">(.*?)</div>)?', re.DOTALL)
regex_category = re.compile(r'<h1.*?>(.*?)</h1>(?:.*?<div class=\"visually-hidden\">(.*?)</div>)?', re.DOTALL)

categories = []
for result in regex_articles.finditer(raw_html):
article_html = result.group(1)

match_category = regex_category.search(article_html)
category_title = match_category.group(1).strip()
if match_category.group(2):
category_title += ' [B]%s[/B]' % match_category.group(2).strip()

# Extract programs and lookup in all_programs so we have more metadata
programs = []
for program in self._extract_programs(article_html):
try:
rich_program = next(rich_program for rich_program in all_programs if rich_program.path == program.path)
programs.append(rich_program)
except StopIteration:
programs.append(program)

episodes = self._extract_videos(article_html)

categories.append(
Category(uuid=hashlib.md5(category_title.encode('utf-8')).hexdigest(), title=category_title, programs=programs, episodes=episodes))
category_title = None
if match_category:
category_title = match_category.group(1).strip()
if match_category.group(2):
category_title += ' [B]%s[/B]' % match_category.group(2).strip()

if category_title:
# Extract programs and lookup in all_programs so we have more metadata
programs = []
for program in self._extract_programs(article_html):
try:
rich_program = next(rich_program for rich_program in all_programs if rich_program.path == program.path)
programs.append(rich_program)
except StopIteration:
programs.append(program)

episodes = self._extract_videos(article_html)

categories.append(
Category(uuid=hashlib.md5(category_title.encode('utf-8')).hexdigest(), title=category_title, programs=programs, episodes=episodes))

return categories

Expand Down Expand Up @@ -595,35 +598,35 @@ def _parse_program_data(data):
"""
# Create Program info
program = Program(
uuid=data['id'],
path=data['link'].lstrip('/'),
channel=data['pageInfo']['brand'],
title=data['title'],
description=html_to_kodi(data['description']),
aired=datetime.fromtimestamp(data.get('pageInfo', {}).get('publishDate')),
poster=data['images']['poster'],
thumb=data['images']['teaser'],
fanart=data['images']['hero'],
uuid=data.get('id'),
path=data.get('link').lstrip('/'),
channel=data.get('pageInfo').get('brand'),
title=data.get('title'),
description=html_to_kodi(data.get('description')),
aired=datetime.fromtimestamp(data.get('pageInfo', {}).get('publishDate', 0.0)),
poster=data.get('images').get('poster'),
thumb=data.get('images').get('teaser'),
fanart=data.get('images').get('teaser'),
)

# Create Season info
program.seasons = {
key: Season(
uuid=playlist['id'],
path=playlist['link'].lstrip('/'),
channel=playlist['pageInfo']['brand'],
title=playlist['title'],
uuid=playlist.get('id'),
path=playlist.get('link').lstrip('/'),
channel=playlist.get('pageInfo').get('brand'),
title=playlist.get('title'),
description=html_to_kodi(playlist.get('description')),
number=playlist['episodes'][0]['seasonNumber'], # You did not see this
number=playlist.get('episodes')[0].get('seasonNumber'), # You did not see this
)
for key, playlist in enumerate(data['playlists']) if playlist['episodes']
for key, playlist in enumerate(data.get('playlists', [])) if playlist.get('episodes')
}

# Create Episodes info
program.episodes = [
ContentApi._parse_episode_data(episode, playlist['id'])
for playlist in data['playlists']
for episode in playlist['episodes']
ContentApi._parse_episode_data(episode, playlist.get('id'))
for playlist in data.get('playlists', [])
for episode in playlist.get('episodes')
]

return program
Expand Down

0 comments on commit 9c44d32

Please sign in to comment.