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 Jun 13, 2024
1 parent 631914a commit 45dce06
Show file tree
Hide file tree
Showing 32 changed files with 593 additions and 746 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ 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]
Expand Down
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.

7 changes: 3 additions & 4 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?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="2.0.0-beta.1" provider-name="Flawe">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.routing" version="0.2.3"/>
Expand All @@ -8,7 +8,6 @@
<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
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.LOGINFO)
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 45dce06

Please sign in to comment.