Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SFR TV services #1248

Merged
merged 15 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ msgctxt "#30033"
msgid "Favourites"
msgstr ""

msgctxt "#30034"
msgid "Internet service providers"
msgstr ""


# Countries (from 30050 to 30079)

Expand Down Expand Up @@ -566,6 +570,15 @@ msgctxt "#30261"
msgid "MyTF1 Password"
msgstr ""

msgctxt "#30262"
msgid "SFR TV login"
msgstr ""

msgctxt "#30263"
msgid "SFR TV password"
msgstr ""


# TV integration (from 30270 to 30289)

msgctxt "#30270"
Expand Down Expand Up @@ -956,6 +969,11 @@ msgctxt "#30731"
msgid "Homepage"
msgstr ""

msgctxt "#30732"
msgid "This content requires a payment. To buy or rent it, go to %s website at this URL : %s"
msgstr ""


# Favourites (from 30800 to 30859)

msgctxt "#30800"
Expand Down
19 changes: 18 additions & 1 deletion resources/language/resource.language.fr_fr/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ msgctxt "#30033"
msgid "Favourites"
msgstr "Favoris"

msgctxt "#30034"
msgid "Internet service providers"
msgstr "Fournisseurs d'accès internet"


# Countries (from 30050 to 30079)

Expand Down Expand Up @@ -566,6 +570,14 @@ msgctxt "#30261"
msgid "Mot de passe MyTF1"
msgstr ""

msgctxt "#30262"
msgid "SFR TV login"
msgstr "Login SFR TV"

msgctxt "#30263"
msgid "SFR TV password"
msgstr "Mot de passe SFR TV"


# TV integration (from 30270 to 30289)

Expand Down Expand Up @@ -824,7 +836,7 @@ msgstr "Ce contenu est protégé par DRM. Le mode téléchargement ne fonctionne

msgctxt "#30604"
msgid "Access to this content requires an account %s. You can provide your credentials for it in the settings of this add-on. If you don't have an account, you can create one at this url %s."
msgstr "Accèss à ce contenu nécessite un compte %s. Vous pouvez configurer votre identifiant et votre mot de passe dans la configuration de cette extension. Si vous n'avez pas de compte, vous pouvez le créer à cette URL %s."
msgstr "Accéder à ce contenu nécessite un compte %s. Vous pouvez configurer votre identifiant et votre mot de passe dans la configuration de cette extension. Si vous n'avez pas de compte, vous pouvez le créer à cette URL %s."

msgctxt "#30605"
msgid "You can now use Kodi's TV feature to watch live TV channels from Catch-up TV & More, follow the tutorial at https://catch-up-tv-and-more.github.io/live_tv_installation/."
Expand Down Expand Up @@ -957,6 +969,11 @@ msgctxt "#30731"
msgid "Homepage"
msgstr "Accueil"

msgctxt "#30732"
msgid "This content requires a payment. To buy or rent it, go to %s website at this URL : %s"
msgstr "Ce contenu est payant. Pour l'acheter ou le louer, rendez-vous sur le site %s à cette URL : %s"


# Favourites (from 30800 to 30859)

msgctxt "#30800"
Expand Down
13 changes: 13 additions & 0 deletions resources/language/resource.language.he_il/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,14 @@ msgctxt "#30261"
msgid "MyTF1 Password"
msgstr ""

msgctxt "#30262"
msgid "SFR TV login"
msgstr ""

msgctxt "#30263"
msgid "SFR TV password"
msgstr ""


# TV integration (from 30270 to 30289)

Expand Down Expand Up @@ -957,6 +965,11 @@ msgctxt "#30731"
msgid "Homepage"
msgstr ""

msgctxt "#30732"
msgid "This content requires a payment. To buy or rent it, go to %s website at this URL : %s"
msgstr ""


# Favourites (from 30800 to 30859)

msgctxt "#30800"
Expand Down
18 changes: 18 additions & 0 deletions resources/language/resource.language.nl_nl/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ msgctxt "#30033"
msgid "Favourites"
msgstr "Favorieten"

msgctxt "#30034"
msgid "Internet service providers"
msgstr "Internetproviders"


# Countries (from 30050 to 30079)

Expand Down Expand Up @@ -566,6 +570,15 @@ msgctxt "#30261"
msgid "MyTF1 Password"
msgstr ""

msgctxt "#30262"
msgid "SFR TV login"
msgstr ""

msgctxt "#30263"
msgid "SFR TV password"
msgstr ""


# TV integration (from 30270 to 30289)

msgctxt "#30270"
Expand Down Expand Up @@ -956,6 +969,11 @@ msgctxt "#30731"
msgid "Homepage"
msgstr ""

msgctxt "#30732"
msgid "This content requires a payment. To buy or rent it, go to %s website at this URL : %s"
msgstr ""


# Favourites (from 30800 to 30859)

msgctxt "#30800"
Expand Down
86 changes: 53 additions & 33 deletions resources/lib/iptvmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,15 @@ def save_tv_integration_settings(j):
# Settings callback functions

def get_all_live_tv_channels():
"""Explore each live_tv skeleton files to retrieve all sorted live tv channels
"""Explore each live_tv skeleton files to retrieve all sorted live tv channels.
The live channels of each internet provider are then added to the list.

Returns:
list: Format: (coutry_order, country_id, country_label, country_infos, [channels]),
list: Format: (group_id, group_label, group_infos, [channels]),
Channel format: (channel_order, channel_id, channel_label, channel_infos, lang)
"""

# Live channels of each country
country_channels = []
live_tv_dict = importlib.import_module('resources.lib.skeletons.live_tv').menu
for country_id, country_infos in live_tv_dict.items():
Expand All @@ -90,8 +93,25 @@ def get_all_live_tv_channels():
else:
channels.append((channel_infos['order'], channel_id, get_item_label(channel_id, channel_infos), channel_infos, None))
channels = sorted(channels, key=lambda x: x[0])
country_channels.append((country_infos['order'], country_id, get_item_label(country_id, country_infos), country_infos, channels))
return sorted(country_channels, key=lambda x: x[2])
country_channels.append((country_id, get_item_label(country_id, country_infos), country_infos, channels))
group_channels = sorted(country_channels, key=lambda x: x[1])

# Live channels of each internet provider
provider_channels = []
providers_dict = importlib.import_module('resources.lib.skeletons.providers').menu
for provider_id, provider_infos in providers_dict.items():
channels = []
# If a function is defined to retrieve a dynamic list of channels for that folder
if 'list_channels_function' in provider_infos:
module_name, function_name = provider_infos['list_channels_function'].split(':')
module = importlib.import_module(module_name)
for ch_infos in getattr(module, function_name)():
channels.append((ch_infos['order'], ch_infos['id'], ch_infos['label'], ch_infos, None))
channels = sorted(channels, key=lambda x: x[0])
provider_channels.append((provider_id + '_live', get_item_label(provider_id, provider_infos), provider_infos, channels))
group_channels.extend(sorted(provider_channels, key=lambda x: x[1]))

return group_channels


@Script.register
Expand All @@ -103,7 +123,7 @@ def select_channels(plugin):
"""

# Grab all live TV channels
country_channels = get_all_live_tv_channels()
group_channels = get_all_live_tv_channels()

# Grab current user settings
tv_integration_settings = get_tv_integration_settings()
Expand All @@ -113,38 +133,38 @@ def select_channels(plugin):
preselect = []
selected_channels_map = []
cnt = 0
for (country_order, country_id, country_label, country_infos, channels) in country_channels:
if country_id not in tv_integration_settings['enabled_channels']:
tv_integration_settings['enabled_channels'][country_id] = {}
for (group_id, group_label, group_infos, channels) in group_channels:
if group_id not in tv_integration_settings['enabled_channels']:
tv_integration_settings['enabled_channels'][group_id] = {}

for (channel_order, channel_id, channel_label, channel_infos, lang) in channels:
channel_key = channel_id if not lang else channel_id + ' ' + lang
if channel_key not in tv_integration_settings['enabled_channels'][country_id]:
tv_integration_settings['enabled_channels'][country_id][channel_key] = {'enabled': False}
if channel_key not in tv_integration_settings['enabled_channels'][group_id]:
tv_integration_settings['enabled_channels'][group_id][channel_key] = {'enabled': False}

label = country_label + ' - ' + channel_label
label = group_label + ' - ' + channel_label
options.append(label)
selected_channels_map.append((country_id, channel_key))
if tv_integration_settings['enabled_channels'][country_id][channel_key]['enabled']:
selected_channels_map.append((group_id, channel_key))
if tv_integration_settings['enabled_channels'][group_id][channel_key]['enabled']:
preselect.append(cnt)
cnt += 1

# Show mulit-select dialog
# Show multi-select dialog
dialog = xbmcgui.Dialog()
selected_channels = dialog.multiselect(Script.localize(30277), options, preselect=preselect)

if selected_channels is None:
return

# By default, disable all channels in the setting file
for country_id in tv_integration_settings['enabled_channels'].keys():
for channel_key in tv_integration_settings['enabled_channels'][country_id].keys():
tv_integration_settings['enabled_channels'][country_id][channel_key]['enabled'] = False
for group_id in tv_integration_settings['enabled_channels'].keys():
for channel_key in tv_integration_settings['enabled_channels'][group_id].keys():
tv_integration_settings['enabled_channels'][group_id][channel_key]['enabled'] = False

# Apply user selection and save settings
for selected_channel in selected_channels:
(country_id, channel_key) = selected_channels_map[selected_channel]
tv_integration_settings['enabled_channels'][country_id][channel_key]['enabled'] = True
(group_id, channel_key) = selected_channels_map[selected_channel]
tv_integration_settings['enabled_channels'][group_id][channel_key]['enabled'] = True

save_tv_integration_settings(tv_integration_settings)

Expand Down Expand Up @@ -176,15 +196,15 @@ def send_channels(self):
channels_list = []

# Grab all live TV channels
country_channels = get_all_live_tv_channels()
group_channels = get_all_live_tv_channels()

# Grab current user settings
tv_integration_settings = get_tv_integration_settings()

for (country_order, country_id, country_label, country_infos, channels) in country_channels:
for (group_id, group_label, group_infos, channels) in group_channels:
for (channel_order, channel_id, channel_label, channel_infos, lang) in channels:
channel_key = channel_id if not lang else channel_id + ' ' + lang
if not tv_integration_settings['enabled_channels'].get(country_id, {}).get(channel_key, {}).get('enabled', False):
if not tv_integration_settings['enabled_channels'].get(group_id, {}).get(channel_key, {}).get('enabled', False):
continue

json_stream = {}
Expand Down Expand Up @@ -220,28 +240,28 @@ def send_epg(self):
epg_channels = {}

# Grab all live TV channels
country_channels = get_all_live_tv_channels()
group_channels = get_all_live_tv_channels()

# Grab current user settings
tv_integration_settings = get_tv_integration_settings()

country_tv_guides = {}
group_tv_guides = {}

xmltv_ids_to_keep = []

# Ierate over each country and enabled channels to grab needed programmes
for (country_order, country_id, country_label, country_infos, channels) in country_channels:
# Iterate over each group and enabled channels to grab needed programmes
for (group_id, group_label, group_infos, channels) in group_channels:
for (channel_order, channel_id, channel_label, channel_infos, lang) in channels:
channel_key = channel_id if not lang else channel_id + ' ' + lang
if not tv_integration_settings['enabled_channels'].get(country_id, {}).get(channel_key, {}).get('enabled', False):
if not tv_integration_settings['enabled_channels'].get(group_id, {}).get(channel_key, {}).get('enabled', False):
continue

# Check if we have programmes for this country
if country_id not in country_tv_guides:
# Check if we have programmes for this group
if group_id not in group_tv_guides:
programmes = []
for day_delta in range(0, 4):
programmes.extend(grab_programmes(country_id, day_delta))
country_tv_guides[country_id] = programmes
programmes.extend(grab_programmes(group_id, day_delta))
group_tv_guides[group_id] = programmes

# Get the correct xmltv id
if lang:
Expand All @@ -251,8 +271,8 @@ def send_epg(self):
if xmltv_id:
xmltv_ids_to_keep.append(xmltv_id)

# Send all programmes of enables channels
for country_id, programmes in country_tv_guides.items():
# Send all programmes of enabled channels
for group_id, programmes in group_tv_guides.items():
for p in programmes:
if p.get('channel') not in xmltv_ids_to_keep:
continue
Expand Down
Empty file.
Loading