Fix pylint warnings/errors

This commit is contained in:
Michaël Arnauts 2023-07-21 22:28:50 +02:00
parent c9ae78f83b
commit 48c993a4e7
8 changed files with 140 additions and 150 deletions

View File

@ -18,6 +18,7 @@ disable=
use-maxsplit-arg, use-maxsplit-arg,
consider-using-from-import, consider-using-from-import,
unspecified-encoding, unspecified-encoding,
broad-exception-raised,
super-with-arguments, # Python 2.7 compatibility super-with-arguments, # Python 2.7 compatibility
raise-missing-from, # Python 2.7 compatibility raise-missing-from, # Python 2.7 compatibility

View File

@ -21,15 +21,15 @@ except ImportError: # Python 2
ADDON = xbmcaddon.Addon() ADDON = xbmcaddon.Addon()
SORT_METHODS = dict( SORT_METHODS = {
unsorted=xbmcplugin.SORT_METHOD_UNSORTED, 'unsorted': xbmcplugin.SORT_METHOD_UNSORTED,
label=xbmcplugin.SORT_METHOD_LABEL_IGNORE_FOLDERS, 'label': xbmcplugin.SORT_METHOD_LABEL_IGNORE_FOLDERS,
title=xbmcplugin.SORT_METHOD_TITLE, 'title': xbmcplugin.SORT_METHOD_TITLE,
episode=xbmcplugin.SORT_METHOD_EPISODE, 'episode': xbmcplugin.SORT_METHOD_EPISODE,
duration=xbmcplugin.SORT_METHOD_DURATION, 'duration': xbmcplugin.SORT_METHOD_DURATION,
year=xbmcplugin.SORT_METHOD_VIDEO_YEAR, 'year': xbmcplugin.SORT_METHOD_VIDEO_YEAR,
date=xbmcplugin.SORT_METHOD_DATE, 'date': xbmcplugin.SORT_METHOD_DATE
) }
DEFAULT_SORT_METHODS = [ DEFAULT_SORT_METHODS = [
'unsorted', 'title' 'unsorted', 'title'
] ]
@ -469,13 +469,13 @@ def open_settings():
def get_global_setting(key): def get_global_setting(key):
"""Get a Kodi setting""" """Get a Kodi setting"""
result = jsonrpc(method='Settings.GetSettingValue', params=dict(setting=key)) result = jsonrpc(method='Settings.GetSettingValue', params={'setting': key})
return result.get('result', {}).get('value') return result.get('result', {}).get('value')
def set_global_setting(key, value): def set_global_setting(key, value):
"""Set a Kodi setting""" """Set a Kodi setting"""
return jsonrpc(method='Settings.SetSettingValue', params=dict(setting=key, value=value)) return jsonrpc(method='Settings.SetSettingValue', params={'setting': key, 'value': value})
def get_cond_visibility(condition): def get_cond_visibility(condition):

View File

@ -42,17 +42,17 @@ class IPTVManager:
streams = [] streams = []
for key, channel in CHANNELS.items(): for key, channel in CHANNELS.items():
if channel.get('iptv_id'): if channel.get('iptv_id'):
streams.append(dict( streams.append({
id=channel.get('iptv_id'), 'id': channel.get('iptv_id'),
name=channel.get('name'), 'name': channel.get('name'),
logo='special://home/addons/{addon}/resources/logos/{logo}'.format(addon=kodiutils.addon_id(), 'logo': 'special://home/addons/{addon}/resources/logos/{logo}'.format(addon=kodiutils.addon_id(),
logo=channel.get('logo')), logo=channel.get('logo')),
preset=channel.get('iptv_preset'), 'preset': channel.get('iptv_preset'),
stream='plugin://plugin.video.viervijfzes/play/live/{channel}'.format(channel=key), 'stream': 'plugin://plugin.video.viervijfzes/play/live/{channel}'.format(channel=key),
vod='plugin://plugin.video.viervijfzes/play/epg/{channel}/{{date}}'.format(channel=key) 'vod': 'plugin://plugin.video.viervijfzes/play/epg/{channel}/{{date}}'.format(channel=key)
)) })
return dict(version=1, streams=streams) return {'version': 1, 'streams': streams}
@via_socket @via_socket
def send_epg(): # pylint: disable=no-method-argument def send_epg(): # pylint: disable=no-method-argument
@ -78,20 +78,21 @@ class IPTVManager:
epg = epg_api.get_epg(key, date.strftime('%Y-%m-%d')) epg = epg_api.get_epg(key, date.strftime('%Y-%m-%d'))
results[iptv_id].extend([ results[iptv_id].extend([
dict( {
start=program.start.isoformat(), 'start': program.start.isoformat(),
stop=(program.start + timedelta(seconds=program.duration)).isoformat(), 'stop': (program.start + timedelta(seconds=program.duration)).isoformat(),
title=program.program_title, 'title': program.program_title,
subtitle=program.episode_title, 'subtitle': program.episode_title,
description=program.description, 'description': program.description,
episode='S%sE%s' % (program.season, program.number) if program.season and program.number else None, 'episode': 'S%sE%s' % (program.season, program.number) if program.season and program.number else None,
genre=program.genre, 'genre': program.genre,
genre_id=program.genre_id, 'genre_id': program.genre_id,
image=program.thumb, 'image': program.thumb,
stream=kodiutils.url_for('play_from_page', 'stream': kodiutils.url_for('play_from_page',
channel=key, channel=key,
page=quote(program.video_url, safe='')) if program.video_url else None) page=quote(program.video_url, safe='')) if program.video_url else None
}
for program in epg if program.duration for program in epg if program.duration
]) ])
return dict(version=1, epg=results) return {'version': 1, 'epg': results}

View File

@ -31,68 +31,68 @@ class Menu:
TitleItem( TitleItem(
title=kodiutils.localize(30001), # A-Z title=kodiutils.localize(30001), # A-Z
path=kodiutils.url_for('show_catalog'), path=kodiutils.url_for('show_catalog'),
art_dict=dict( art_dict={
icon='DefaultMovieTitle.png', 'icon': 'DefaultMovieTitle.png',
fanart=kodiutils.get_addon_info('fanart'), 'fanart': kodiutils.get_addon_info('fanart')
), },
info_dict=dict( info_dict={
plot=kodiutils.localize(30002), 'plot': kodiutils.localize(30002)
) }
), ),
TitleItem( TitleItem(
title=kodiutils.localize(30007), # TV Channels title=kodiutils.localize(30007), # TV Channels
path=kodiutils.url_for('show_channels'), path=kodiutils.url_for('show_channels'),
art_dict=dict( art_dict={
icon='DefaultAddonPVRClient.png', 'icon': 'DefaultAddonPVRClient.png',
fanart=kodiutils.get_addon_info('fanart'), 'fanart': kodiutils.get_addon_info('fanart')
), },
info_dict=dict( info_dict={
plot=kodiutils.localize(30008), 'plot': kodiutils.localize(30008)
) }
), ),
TitleItem( TitleItem(
title=kodiutils.localize(30003), # Catalog title=kodiutils.localize(30003), # Catalog
path=kodiutils.url_for('show_categories'), path=kodiutils.url_for('show_categories'),
art_dict=dict( art_dict={
icon='DefaultGenre.png', 'icon': 'DefaultGenre.png',
fanart=kodiutils.get_addon_info('fanart'), 'fanart': kodiutils.get_addon_info('fanart')
), },
info_dict=dict( info_dict={
plot=kodiutils.localize(30004), 'plot': kodiutils.localize(30004)
) }
), ),
TitleItem( TitleItem(
title=kodiutils.localize(30005), # Recommendations title=kodiutils.localize(30005), # Recommendations
path=kodiutils.url_for('show_recommendations'), path=kodiutils.url_for('show_recommendations'),
art_dict=dict( art_dict={
icon='DefaultFavourites.png', 'icon': 'DefaultFavourites.png',
fanart=kodiutils.get_addon_info('fanart'), 'fanart': kodiutils.get_addon_info('fanart')
), },
info_dict=dict( info_dict={
plot=kodiutils.localize(30006), 'plot': kodiutils.localize(30006)
) }
), ),
TitleItem( TitleItem(
title=kodiutils.localize(30011), # My List title=kodiutils.localize(30011), # My List
path=kodiutils.url_for('show_mylist'), path=kodiutils.url_for('show_mylist'),
art_dict=dict( art_dict={
icon='DefaultPlaylist.png', 'icon': 'DefaultPlaylist.png',
fanart=kodiutils.get_addon_info('fanart'), 'fanart': kodiutils.get_addon_info('fanart')
), },
info_dict=dict( info_dict={
plot=kodiutils.localize(30012), 'plot': kodiutils.localize(30012)
) }
), ),
TitleItem( TitleItem(
title=kodiutils.localize(30009), # Search title=kodiutils.localize(30009), # Search
path=kodiutils.url_for('show_search'), path=kodiutils.url_for('show_search'),
art_dict=dict( art_dict={
icon='DefaultAddonsSearch.png', 'icon': 'DefaultAddonsSearch.png',
fanart=kodiutils.get_addon_info('fanart'), 'fanart': kodiutils.get_addon_info('fanart')
), },
info_dict=dict( info_dict={
plot=kodiutils.localize(30010), 'plot': kodiutils.localize(30010)
) }
) )
] ]

View File

@ -38,7 +38,7 @@ class Player:
# self.play_from_page(broadcast.video_url) # self.play_from_page(broadcast.video_url)
# return # return
channel_name = CHANNELS.get(channel, dict(name=channel)) channel_name = CHANNELS.get(channel, {'name': channel})
kodiutils.ok_dialog(message=kodiutils.localize(30718, channel=channel_name.get('name'))) # There is no live stream available for {channel}. kodiutils.ok_dialog(message=kodiutils.localize(30718, channel=channel_name.get('name'))) # There is no live stream available for {channel}.
kodiutils.end_of_directory() kodiutils.end_of_directory()

View File

@ -5,68 +5,56 @@ from __future__ import absolute_import, division, unicode_literals
from collections import OrderedDict from collections import OrderedDict
CHANNELS = OrderedDict([ CHANNELS = OrderedDict([
('Play4', dict( ('Play4', {
name='Play4', 'name': 'Play4',
epg_id='vier', 'epg_id': 'vier',
logo='play4.png', 'logo': 'play4.png',
background='play4-background.png', 'background': 'play4-background.png',
iptv_preset=4, 'iptv_preset': 4,
iptv_id='play4.be', 'iptv_id': 'play4.be',
youtube=[ 'youtube': [
dict( {'label': 'GoPlay', 'logo': 'goplay.png', 'path': 'plugin://plugin.video.youtube/user/viertv/'},
label='GoPlay', ]
logo='goplay.png', }),
path='plugin://plugin.video.youtube/user/viertv/', ('Play5', {
), 'name': 'Play5',
], 'epg_id': 'vijf',
)), 'logo': 'play5.png',
('Play5', dict( 'background': 'play5-background.png',
name='Play5', 'iptv_preset': 5,
epg_id='vijf', 'iptv_id': 'play5.be',
logo='play5.png', 'youtube': [
background='play5-background.png', {'label': 'GoPlay', 'logo': 'goplay.png', 'path': 'plugin://plugin.video.youtube/user/viertv/'},
iptv_preset=5, ]
iptv_id='play5.be', }),
youtube=[ ('Play6', {
dict( 'name': 'Play6',
label='GoPlay', 'epg_id': 'zes',
logo='goplay.png', 'logo': 'play6.png',
path='plugin://plugin.video.youtube/user/viertv/', 'background': 'play6-background.png',
), 'iptv_preset': 6,
], 'iptv_id': 'play6.be',
)), 'youtube': [
('Play6', dict( {'label': 'GoPlay', 'logo': 'goplay.png', 'path': 'plugin://plugin.video.youtube/user/viertv/'},
name='Play6', ]
epg_id='zes', }),
logo='play6.png', ('Play7', {
background='play6-background.png', 'name': 'Play7',
iptv_preset=6, 'epg_id': 'zeven',
iptv_id='play6.be', 'url': 'https://www.goplay.be',
youtube=[ 'logo': 'play7.png',
dict( 'background': 'play7-background.png',
label='GoPlay', 'iptv_preset': 17,
logo='goplay.png', 'iptv_id': 'play7.be',
path='plugin://plugin.video.youtube/user/viertv/', 'youtube': []
), }),
], ('GoPlay', {
)), 'name': 'Go Play',
('Play7', dict( 'url': 'https://www.goplay.be',
name='Play7', 'logo': 'goplay.png',
epg_id='zeven', 'background': 'goplay-background.png',
url='https://www.goplay.be', 'youtube': []
logo='play7.png', })
background='play7-background.png',
iptv_preset=17,
iptv_id='play7.be',
youtube=[],
)),
('GoPlay', dict(
name='Go Play',
url='https://www.goplay.be',
logo='goplay.png',
background='goplay-background.png',
youtube=[],
))
]) ])
STREAM_DICT = { STREAM_DICT = {

View File

@ -79,11 +79,11 @@ class AuthApi:
if not os.path.exists(self._token_path): if not os.path.exists(self._token_path):
os.makedirs(self._token_path) os.makedirs(self._token_path)
with open(os.path.join(self._token_path, self.TOKEN_FILE), 'w') as fdesc: with open(os.path.join(self._token_path, self.TOKEN_FILE), 'w') as fdesc:
data = json.dumps(dict( data = json.dumps({
id_token=self._id_token, 'id_token': self._id_token,
refresh_token=self._refresh_token, 'refresh_token': self._refresh_token,
expiry=self._expiry, 'expiry': self._expiry
)) })
fdesc.write(kodiutils.from_unicode(data)) fdesc.write(kodiutils.from_unicode(data))
return self._id_token return self._id_token

View File

@ -312,7 +312,7 @@ class ContentApi:
video_id = json.loads(unescape(result.group(1)))['id'] video_id = json.loads(unescape(result.group(1)))['id']
video_json_data = self._get_url('%s/web/v1/videos/short-form/%s' % (self.API_GOPLAY, video_id)) video_json_data = self._get_url('%s/web/v1/videos/short-form/%s' % (self.API_GOPLAY, video_id))
video_json = json.loads(video_json_data) video_json = json.loads(video_json_data)
return dict(video=video_json) return {'video': video_json}
# Extract program JSON # Extract program JSON
regex_program = re.compile(r'data-hero="([^"]+)', re.DOTALL) regex_program = re.compile(r'data-hero="([^"]+)', re.DOTALL)
@ -328,7 +328,7 @@ class ContentApi:
episode_json_data = unescape(result.group(1)) episode_json_data = unescape(result.group(1))
episode_json = json.loads(episode_json_data) episode_json = json.loads(episode_json_data)
return dict(program=program_json, episode=episode_json) return {'program': program_json, 'episode': episode_json}
# Fetch listing from cache or update if needed # Fetch listing from cache or update if needed
data = self._handle_cache(key=['episode', path], cache_mode=cache, update=update) data = self._handle_cache(key=['episode', path], cache_mode=cache, update=update)
@ -370,9 +370,9 @@ class ContentApi:
# See https://docs.unified-streaming.com/documentation/drm/buydrm.html#setting-up-the-client # See https://docs.unified-streaming.com/documentation/drm/buydrm.html#setting-up-the-client
# Generate license key # Generate license key
license_key = self.create_license_key('https://wv-keyos.licensekeyserver.com/', key_headers=dict( license_key = self.create_license_key('https://wv-keyos.licensekeyserver.com/', key_headers={
customdata=data['drmXml'], 'customdata': data['drmXml']
)) })
# Get manifest url # Get manifest url
if data.get('manifestUrls'): if data.get('manifestUrls'):