Skip to content

Commit

Permalink
Add Orange auth and rework plugin architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
f-lawe committed Jul 5, 2024
1 parent 46a500c commit 95e6fb7
Show file tree
Hide file tree
Showing 34 changed files with 709 additions and 759 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,27 @@ jobs:
strategy:
fail-fast: false
matrix:
kodi-version: [ matrix ]
python-version: [ 3.9 ]
kodi-version: [ nexus ]
python-version: [ 3.8 ]
steps:
- name: Check out ${{ github.sha }} from repository ${{ github.repository }}
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: pip install -r ./requirements.txt

- name: Run pylint
run: pylint ./resources
- name: Run ruff
run: ruff check .

- name: Run kodi-addon-checker
uses: xbmc/[email protected]
with:
rewrite-for-matrix: true
is-pr: true
rewrite-for-matrix: false
kodi-version: ${{ matrix.kodi-version }}
addon-id: ${{ github.event.repository.name }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.ruff_cache
.vscode

*.py[cod]
__pycache__
__pycache__
11 changes: 0 additions & 11 deletions .pylintrc

This file was deleted.

10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Orange TV France for Kodi
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/BreizhReloaded/plugin.video.orange.fr)](https://github.com/BreizhReloaded/plugin.video.orange.fr/releases)
[![Kodi version](https://img.shields.io/badge/kodi%20version-v19-blue)](https://kodi.tv/)
[![GitHub](https://img.shields.io/github/license/BreizhReloaded/plugin.video.orange.fr)](https://github.com/BreizhReloaded/plugin.video.orange.fr/blob/master/LICENSE)
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/f-lawe/plugin.video.orange.fr)](https://github.com/f-lawe/plugin.video.orange.fr/releases)
[![Kodi version](https://img.shields.io/badge/kodi%20version-v21-blue)](https://kodi.tv/)
[![GitHub](https://img.shields.io/github/license/f-lawe/plugin.video.orange.fr)](https://github.com/f-lawe/plugin.video.orange.fr/blob/master/LICENSE)

____ _[Lisez-moi](docs/README.fr.md) en français_

Expand All @@ -11,12 +11,10 @@ _This addon is not officially commissioned/supported by Orange. All product name
This addon brings Orange TV to Kodi. All channels included in your registration are now directly available from Kodi!

## Installation
Download the latest ZIP archive from the [releases page](https://github.com/BreizhReloaded/plugin.video.orange.fr/releases/latest) and install it into Kodi (Settings > Addons > Install from ZIP). Then install the dependencies from the addon screen (My addons > Video addons > Orange TV France > Dependencies).
Download the latest ZIP archive from the [releases page](https://github.com/f-lawe/plugin.video.orange.fr/releases/latest) and install it into Kodi (Settings > Addons > Install from ZIP). Then install the dependencies from the addon screen (My addons > Video addons > Orange TV France > Dependencies).

Integration to Kodi TV is handled via [IPTV Manager](https://github.com/add-ons/service.iptv.manager). You can install and activate it from the addon settings. Once set up on your system, channels and TV guide are loaded automatically.

_NB: you can also choose the basic integration, in that case you need to manually pass to [IPTV Simple](https://github.com/kodi-pvr/pvr.iptvsimple) the .m3u8 and .xml files located within the data directory._

You should now be able to view all the channels grouped by category in the TV section. If that's not already installed, Kodi will ask you to install the decrypting tool when accessing a channel for the first time.

Do not forget to properly configure IPTV Manager and select your TV provider in the settings!
Expand Down
9 changes: 4 additions & 5 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.orange.fr" name="Orange TV France" version="1.5.0" provider-name="BreizhReloaded">
<addon id="plugin.video.orange.fr" name="Orange TV France" version="1.5.0" provider-name="Flawe">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="xbmc.python" version="3.0.1"/>
<import addon="script.module.routing" version="0.2.3"/>
<import addon="script.module.inputstreamhelper" version="0.5.2"/>
</requires>
<extension point="xbmc.python.pluginsource" library="resources/addon.py">
<provides>video</provides>
</extension>
<extension point="xbmc.service" library="resources/service.py"/>
<extension point="xbmc.addon.metadata">
<summary lang="en">Watch TV channels provided by your Orange subscription from Kodi!</summary>
<description lang="en">This addon brings to Kodi all the TV channels included in your Orange subscription. Easy install via IPTV Manager.</description>
Expand All @@ -19,8 +18,8 @@
<platform>all</platform>
<license>MIT</license>
<forum>https://forum.kodi.tv/showthread.php?tid=360391</forum>
<source>https://github.com/BreizhReloaded/plugin.video.orange.fr</source>
<email>[email protected]</email>
<source>https://github.com/f-lawe/plugin.video.orange.fr</source>
<email>[email protected]</email>
<assets>
<icon>resources/media/icon.png</icon>
<fanart>resources/media/fanart.jpg</fanart>
Expand Down
8 changes: 3 additions & 5 deletions docs/README.fr.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Orange TV France pour Kodi
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/BreizhReloaded/plugin.video.orange.fr)](https://github.com/BreizhReloaded/plugin.video.orange.fr/releases)
[![Kodi version](https://img.shields.io/badge/kodi%20version-v19-blue)](https://kodi.tv/)
[![GitHub](https://img.shields.io/github/license/BreizhReloaded/plugin.video.orange.fr)](https://github.com/BreizhReloaded/plugin.video.orange.fr/blob/master/LICENSE)
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/f-lawe/plugin.video.orange.fr)](https://github.com/f-lawe/plugin.video.orange.fr/releases)
[![Kodi version](https://img.shields.io/badge/kodi%20version-v21-blue)](https://kodi.tv/)
[![GitHub](https://img.shields.io/github/license/f-lawe/plugin.video.orange.fr)](https://github.com/f-lawe/plugin.video.orange.fr/blob/master/LICENSE)

_Cet addon n'est pas officiellement supporté par Orange. Tous les produits, logos et marques déposées mentionnés dans ce projet sont la propriété de leurs propriétaires respectifs._

Expand All @@ -13,8 +13,6 @@ Téléchargez l'archive de la [dernière version](https://github.com/BreizhReloa

L'intégration à la télévision sur Kodi se fait via [IPTV Manager](https://github.com/add-ons/service.iptv.manager). Vous pouvez l'installer et l'activer directement depuis les réglages de l'addon. Une fois configuré, les chaînes et le programme TV se chargent automatiquement.

_NB: vous pouvez également choisir l'intégration basique, dans ce cas vous devez passer manuellement à [IPTV Simple](https://github.com/kodi-pvr/pvr.iptvsimple) les fichiers .m3u8 et .xml situés dans le dossier data._

Vous devriez maintenant voir toutes les chaînes regroupées par categories dans la section TV. S'il n'est pas déjà installé, Kodi vous demandera d'installer l'outil de décryptage quand vous regarderez une chaîne pour la première fois.

N'oubliez pas de configurer IPTV Manager correctement et de sélectionner le bon fournisseur dans les paramètres !
Expand Down
27 changes: 27 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[project]
requires-python = ">=3.8"

[tool.ruff]
line-length = 120
target-version = "py38"

[tool.ruff.format]
docstring-code-format = false
docstring-code-line-length = "dynamic"
indent-style = "space"
line-ending = "auto"
quote-style = "double"
skip-magic-trailing-comma = false

[tool.ruff.lint]
fixable = ["ALL"]
ignore = ["D203", "D213"]
select = [
"E", # pycodestyle
"F", # Pyflakes
"UP", # pyupgrade
"B", # flake8-bugbear
"SIM", # flake8-simplify
"I", # isort
"D", # pydocstyle
]
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
kodistubs==19.*
pylint==2.14.*
kodistubs==21.*
ruff==0.3.*
83 changes: 36 additions & 47 deletions resources/addon.py
Original file line number Diff line number Diff line change
@@ -1,58 +1,47 @@
# -*- coding: utf-8 -*-
"""Addon entry point"""
import routing # pylint: disable=import-error
import inputstreamhelper # pylint: disable=import-error
import xbmcgui
import xbmcplugin
"""Addon entry point."""

import sys

import xbmc
import xbmcplugin
from lib.channelmanager import ChannelManager
from lib.iptvmanager import IPTVManager
from lib.providers import get_provider
from lib.utils import localize, log, LogLevel, ok_dialog
from lib.utils.xbmc import log, ok_dialog
from routing import Plugin

plugin = routing.Plugin()
router = Plugin()

@plugin.route('/')

@router.route("/")
def index():
"""Addon index"""
ok_dialog(localize(30902))
"""Display a welcome message."""
log("Hello from plugin.video.orange.fr", xbmc.LOGINFO)
ok_dialog("Hello from plugin.video.orange.fr")


@plugin.route('/channel/<channel_id>')
@router.route("/channels/<channel_id>")
def channel(channel_id: str):
"""Load stream for the required channel id"""
log(f'Loading channel {channel_id}', LogLevel.INFO)

stream = get_provider().get_stream_info(channel_id)
if not stream:
ok_dialog(localize(30900))
return

is_helper = inputstreamhelper.Helper(stream['manifest_type'], drm=stream['drm'])
if not is_helper.check_inputstream():
ok_dialog(localize(30901))
return

listitem = xbmcgui.ListItem(path=stream['path'])
listitem.setMimeType(stream['mime_type'])
listitem.setProperty('inputstream', 'inputstream.adaptive')
listitem.setProperty('inputstream.adaptive.manifest_type', stream['manifest_type'])
listitem.setProperty('inputstream.adaptive.manifest_update_parameter', 'full')
listitem.setProperty('inputstream.adaptive.license_type', stream['license_type'])
listitem.setProperty('inputstream.adaptive.license_key', stream['license_key'])
xbmcplugin.setResolvedUrl(plugin.handle, True, listitem=listitem)

@plugin.route('/iptv/channels')
"""Load stream for the required channel id."""
log(f"Loading channel {channel_id}", xbmc.LOGINFO)
xbmcplugin.setResolvedUrl(router.handle, True, listitem=ChannelManager().load_channel_listitem(channel_id))


@router.route("/iptv/channels")
def iptv_channels():
"""Return JSON-STREAMS formatted data for all live channels"""
log('Loading channels for IPTV Manager', LogLevel.INFO)
port = int(plugin.args.get('port')[0])
IPTVManager(port, get_provider()).send_channels()
"""Return JSON-STREAMS formatted data for all live channels."""
log("Loading channels for IPTV Manager", xbmc.LOGINFO)
port = int(router.args.get("port")[0])
IPTVManager(port).send_channels()

@plugin.route('/iptv/epg')

@router.route("/iptv/epg")
def iptv_epg():
"""Return JSON-EPG formatted data for all live channel EPG data"""
log('Loading EPG for IPTV Manager', LogLevel.INFO)
port = int(plugin.args.get('port')[0])
IPTVManager(port, get_provider()).send_epg()
"""Return JSON-EPG formatted data for all live channel EPG data."""
log("Loading EPG for IPTV Manager")
port = int(router.args.get("port")[0])
IPTVManager(port).send_epg()


if __name__ == '__main__':
plugin.run()
if __name__ == "__main__":
log(sys.version, xbmc.LOGDEBUG)
router.run()
24 changes: 4 additions & 20 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,21 @@ msgid "TV Integration"
msgstr ""

msgctxt "#30101"
msgid "Enable IPTV Manager integration"
msgid "Install IPTV Manager"
msgstr ""

msgctxt "#30102"
msgid "Help 30102"
msgstr ""
msgid "Help 30104"
msgstr "
msgctxt "#30103"
msgid "Install IPTV Manager…"
msgid "Go to IPTV Manager settings…"
msgstr ""

msgctxt "#30104"
msgid "Help 30104"
msgstr ""

msgctxt "#30105"
msgid "Go to IPTV Manager settings…"
msgstr ""

msgctxt "#30106"
msgid "Help 30106"
msgstr ""

msgctxt "#30111"
msgid "Enable basic integration"
msgstr ""

msgctxt "#30112"
msgid "Help 30112"
msgstr ""

# Provider settings (from 30200 to 30299)

msgctxt "#30200"
Expand Down
24 changes: 4 additions & 20 deletions resources/language/resource.language.fr_fr/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,19 @@ msgid "TV Integration"
msgstr "Intégration TV"

msgctxt "#30101"
msgid "Enable IPTV Manager integration"
msgstr "Activer l'intégration avec IPTV Manager"

msgctxt "#30102"
msgid "Help 30102"
msgstr ""

msgctxt "#30103"
msgid "Install IPTV Manager…"
msgstr "Installer IPTV Manager…"

msgctxt "#30104"
msgctxt "#30102"
msgid "Help 30104"
msgstr ""

msgctxt "#30105"
msgctxt "#30103"
msgid "Go to IPTV Manager settings…"
msgstr "Ouvrir les paramètres de IPTV Manager…"

msgctxt "#30106"
msgid "Help 30106"
msgstr ""

msgctxt "#30111"
msgid "Enable basic integration"
msgstr "Activer l'intégration basique"

msgctxt "#30112"
msgid "Help 30112"
msgctxt "#30104"
msgid "Help 30104"
msgstr ""

# Provider settings (from 30200 to 30299)
Expand Down
3 changes: 1 addition & 2 deletions resources/lib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
# pylint: disable=missing-module-docstring
# noqa: D104
32 changes: 32 additions & 0 deletions resources/lib/channelmanager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Channel stream loader."""

import inputstreamhelper
import xbmcgui

from lib.providers import get_provider
from lib.utils.xbmc import localize, ok_dialog


class ChannelManager:
"""."""

def load_channel_listitem(self, channel_id: str):
"""."""
stream = get_provider().get_stream_info(channel_id)
if not stream:
ok_dialog(localize(30900))
return

is_helper = inputstreamhelper.Helper(stream["manifest_type"], drm=stream["drm"])
if not is_helper.check_inputstream():
ok_dialog(localize(30901))
return

listitem = xbmcgui.ListItem(path=stream["path"])
listitem.setMimeType(stream["mime_type"])
listitem.setContentLookup(False)
listitem.setProperty("inputstream", "inputstream.adaptive")
listitem.setProperty("inputstream.adaptive.license_type", stream["license_type"])
listitem.setProperty("inputstream.adaptive.license_key", stream["license_key"])

return listitem
4 changes: 0 additions & 4 deletions resources/lib/generators/__init__.py

This file was deleted.

Loading

0 comments on commit 95e6fb7

Please sign in to comment.