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,
consider-using-from-import,
unspecified-encoding,
broad-exception-raised,
super-with-arguments, # Python 2.7 compatibility
raise-missing-from, # Python 2.7 compatibility

View File

@ -21,15 +21,15 @@ except ImportError: # Python 2
ADDON = xbmcaddon.Addon()
SORT_METHODS = dict(
unsorted=xbmcplugin.SORT_METHOD_UNSORTED,
label=xbmcplugin.SORT_METHOD_LABEL_IGNORE_FOLDERS,
title=xbmcplugin.SORT_METHOD_TITLE,
episode=xbmcplugin.SORT_METHOD_EPISODE,
duration=xbmcplugin.SORT_METHOD_DURATION,
year=xbmcplugin.SORT_METHOD_VIDEO_YEAR,
date=xbmcplugin.SORT_METHOD_DATE,
)
SORT_METHODS = {
'unsorted': xbmcplugin.SORT_METHOD_UNSORTED,
'label': xbmcplugin.SORT_METHOD_LABEL_IGNORE_FOLDERS,
'title': xbmcplugin.SORT_METHOD_TITLE,
'episode': xbmcplugin.SORT_METHOD_EPISODE,
'duration': xbmcplugin.SORT_METHOD_DURATION,
'year': xbmcplugin.SORT_METHOD_VIDEO_YEAR,
'date': xbmcplugin.SORT_METHOD_DATE
}
DEFAULT_SORT_METHODS = [
'unsorted', 'title'
]
@ -469,13 +469,13 @@ def open_settings():
def get_global_setting(key):
"""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')
def set_global_setting(key, value):
"""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):

View File

@ -42,17 +42,17 @@ class IPTVManager:
streams = []
for key, channel in CHANNELS.items():
if channel.get('iptv_id'):
streams.append(dict(
id=channel.get('iptv_id'),
name=channel.get('name'),
logo='special://home/addons/{addon}/resources/logos/{logo}'.format(addon=kodiutils.addon_id(),
streams.append({
'id': channel.get('iptv_id'),
'name': channel.get('name'),
'logo': 'special://home/addons/{addon}/resources/logos/{logo}'.format(addon=kodiutils.addon_id(),
logo=channel.get('logo')),
preset=channel.get('iptv_preset'),
stream='plugin://plugin.video.viervijfzes/play/live/{channel}'.format(channel=key),
vod='plugin://plugin.video.viervijfzes/play/epg/{channel}/{{date}}'.format(channel=key)
))
'preset': channel.get('iptv_preset'),
'stream': 'plugin://plugin.video.viervijfzes/play/live/{channel}'.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
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'))
results[iptv_id].extend([
dict(
start=program.start.isoformat(),
stop=(program.start + timedelta(seconds=program.duration)).isoformat(),
title=program.program_title,
subtitle=program.episode_title,
description=program.description,
episode='S%sE%s' % (program.season, program.number) if program.season and program.number else None,
genre=program.genre,
genre_id=program.genre_id,
image=program.thumb,
stream=kodiutils.url_for('play_from_page',
{
'start': program.start.isoformat(),
'stop': (program.start + timedelta(seconds=program.duration)).isoformat(),
'title': program.program_title,
'subtitle': program.episode_title,
'description': program.description,
'episode': 'S%sE%s' % (program.season, program.number) if program.season and program.number else None,
'genre': program.genre,
'genre_id': program.genre_id,
'image': program.thumb,
'stream': kodiutils.url_for('play_from_page',
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
])
return dict(version=1, epg=results)
return {'version': 1, 'epg': results}

View File

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

View File

@ -38,7 +38,7 @@ class Player:
# self.play_from_page(broadcast.video_url)
# 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.end_of_directory()

View File

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

View File

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

View File

@ -312,7 +312,7 @@ class ContentApi:
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 = json.loads(video_json_data)
return dict(video=video_json)
return {'video': video_json}
# Extract program JSON
regex_program = re.compile(r'data-hero="([^"]+)', re.DOTALL)
@ -328,7 +328,7 @@ class ContentApi:
episode_json_data = unescape(result.group(1))
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
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
# Generate license key
license_key = self.create_license_key('https://wv-keyos.licensekeyserver.com/', key_headers=dict(
customdata=data['drmXml'],
))
license_key = self.create_license_key('https://wv-keyos.licensekeyserver.com/', key_headers={
'customdata': data['drmXml']
})
# Get manifest url
if data.get('manifestUrls'):