Skip to content

Commit

Permalink
[plugin.video.eitb] 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
erral committed Feb 19, 2023
1 parent 070e763 commit 9e06689
Show file tree
Hide file tree
Showing 20 changed files with 1,545 additions and 0 deletions.
674 changes: 674 additions & 0 deletions plugin.video.eitb/LICENSE.txt

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions plugin.video.eitb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# EITB plugin

This plugin allows to use the videos and audios in EITB Nahieran in your Kodi

[Irakurri euskaraz](README_eu.md)

[En español](README_es.md)


[![Video demo](https://i.ibb.co/Nrt2GqL/eitb-kodi-yt.png)](https://vimeo.com/536953558)

### Based on

Based on [plugin.video.example](https://github.com/romanvm/plugin.video.example/) by romanvm (GPLv3)
Based on [plugin.audio.example](https://github.com/zag2me/plugin.audio.example) by zag2me (GPLv2)

## Downloads

Download from [releases page](https://github.com/erral/plugin.video.eitb/releases)

## License (GPLv3)

See [LICENSE.txt](LICENSE.txt)


## Icons author
https://fontawesome.com/
34 changes: 34 additions & 0 deletions plugin.video.eitb/README_es.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# plugin.video.eitb

Este plugin permite ver todos los contenidos de EITB Nahieran en Kodi

## Instalación

[Descarta la última versión](https://github.com/erral/plugin.video.eitb/releases)
en formato zip.

Abre Kodi y entra a Sistema -> Ajustes -> Add-ons -> Instalar desde archivo .zip
y ahí elige el archivo zip que acabas de descargar.

## Uso

El plugin aparecerá en los apartados de Vídeos y Música. En el primero se verán
los programas de TV y en el segundo los de radio.


## Futuros cambios

Entre las cosas pendientes quiero hacer lo siguiente:

- organizar los listados de programas también por tipo, últimos, los más vistos, ...
como lo hace la web.

- organizar los programas de radio por tipo y radio.


## Preguntas

Si tenéis preguntas o propuestas de mejora, podéis escribirme directamente
(larreategi arroba eibar.org) o abrir un ticket [en la cuenta de GitHub](https://github.com/erral/plugin.video.eitb/issues)

[Descargar desde GitHub](https://github.com/erral/plugin.video.eitb/releases)
33 changes: 33 additions & 0 deletions plugin.video.eitb/README_eu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# plugin.video.eitb

Plugin honekin EITB Nahieran ikusi dezakezu zure Kodi instalazioan


## Instalazioa

[Deskargatu azken bertsio-paketea](https://github.com/erral/plugin.video.eitb/releases)
zip formatuan.

Ireki Kodi eta joan Sistema -> Ezarpenak -> Gehigarriak -> Instalatu zip
fitxategitik menura, eta aukeratu deskargatutako zip fitxategia.


## Erabilera

Menu nagusitik, 'Bideoak' eta 'Musika' ataletan agertuko da plugina, lehenengoan
telebistako programak ikusi daitezke, bigarrenean irratikoak.


## Egiteke

Egiteke dauden gauzen artean, hemen batzuk:

- programa zerrendak era antolatuan ere erakutsi webgunean egiten den bezala: motaka, azkenak, ikusienak, albistegiak, ...

- irrati-programak saio-motaka eta irratika ere antolatu


## Galderak eta eskariak

Galderak eta hobekuntzak hemendik eskatzeko idatzi niri zuzenean
(larreategi a-bildua eibar.org) edo ireki ticket bat [GitHubeko kontuan](https://github.com/erral/plugin.video.eitb/issues)
84 changes: 84 additions & 0 deletions plugin.video.eitb/addon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
from urllib.parse import parse_qsl
from video import VideoHandler
from audio import AudioHandler

import sys
import xbmcaddon
import xbmc

addon = xbmcaddon.Addon()

# Get the plugin url in plugin:// notation.
_url = sys.argv[0]
# Get the plugin handle as an integer number.
_handle = int(sys.argv[1])

vh = VideoHandler(_handle, _url)
ah = AudioHandler(_handle, _url)


def router(paramstring):
"""
Router function that calls other functions
depending on the provided paramstring
:param paramstring:
"""
# Parse a URL-encoded paramstring to the dictionary of
# {<parameter>: <value>} elements
params = dict(parse_qsl(paramstring))
# Check the parameters passed to the plugin
if params:
if "content_type" in params:
if params["content_type"] == "video":
vh.list_menu()
# vh.list_programs()
elif params["content_type"] == "audio":
ah.list_radios()
# ah.list_radio_programs()
else:
if "action" in params:
if params["action"] == "videomenu":
# Display the list of videos in a provided category.
if params["option"] == "all_tvshows":
vh.list_programs()
# elif params['option'] == 'last_tvshows':
# vh.list_last_broadcast()
elif params["option"] == "program-type-list":
vh.list_programs_types()
elif params["action"] == "videotypelisting":
# Display the list of videos in a provided category.
vh.list_programs_types_playlist(params["program"])
elif params["action"] == "videolisting":
# Display the list of videos in a provided category.
vh.list_playlists(params["program"])
# vh.list_episodes(params['program'])
elif params["action"] == "videoprogram":
# Display the list of videos in a provided program.
vh.list_episodes(params["program"])
elif params["action"] == "videoepisode":
# Display the list of videos in a provided category.
vh.list_videos(params["program"])
elif params["action"] == "videoplay":
# Play a video from a provided URL.
vh.play_video(params["video"])
elif params["action"] == "audioplay":
ah.play_audio(params["program"])
elif params["action"] == "radio":
ah.list_radio_programs(params["program"])
elif params["action"] == "audioprogram":
ah.list_seasons(params["program"])
elif params["action"] == "audioseason":
ah.list_program_season_chapters(params["program"])
elif params["action"] == "audiochapter":
ah.list_program_audios(params["program"])
else:
# If the plugin is called from Kodi UI without any parameters,
# display the list of video categories
vh.list_programs()


if __name__ == "__main__":
# Call the router function and pass the plugin call parameters to it.
# We use string slicing to trim the leading '?' from the plugin call paramstring
router(sys.argv[2][1:])
27 changes: 27 additions & 0 deletions plugin.video.eitb/addon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.eitb" name="EITB Nahieran (unofficial)" version="3.0.0" provider-name="Mikel Larreategi">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.requests" version="2.22.0"/>
</requires>
<extension point="xbmc.python.pluginsource" library="addon.py">
<provides>video audio</provides>
</extension>
<extension point="xbmc.addon.metadata">
<platform>all</platform>
<summary lang="en_GB">Plugin for EITB online service</summary>
<description lang="en_GB">Plugin for EITB using the unofficial REST API</description>
<summary lang="eu">EITB Nahieranentzako plugina</summary>
<description lang="eu">EITB Nahieranen API ez ofiziala erabiliz egindakoa</description>
<summary lang="es_ES">Plugin para EITB a la carta</summary>
<description lang="es_ES">Hecho con la API no oficial de EITB a la carta</description>
<license>GPL-3.0-only</license>
<source>https://github.com/erral/plugin.video.eitb</source>
<website>https://github.com/erral/plugin.video.eitb</website>
<email>[email protected]</email>
<assets>
<icon>icon.png</icon>
<fanart>fanart.jpg</fanart>
</assets>
</extension>
</addon>
110 changes: 110 additions & 0 deletions plugin.video.eitb/audio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
from utils import get_radio_programs
from utils import get_program_audios
from utils import get_radios
from utils import get_program_seasons
from utils import get_program_season_chapters
import xbmcgui
import xbmcplugin


class AudioHandler(object):
def __init__(self, handle, url):
self.handle = handle
self.url = url

def list_radios(self):
listing = []
for radio in get_radios():
title = radio.get("title")
radio_url = radio.get("@id")
list_item = xbmcgui.ListItem(label=title)
list_item.setInfo("music", {"title": title, "album": title})
url = "{0}?action=radio&program={1}".format(self.url, radio_url)
is_folder = True
listing.append((url, list_item, is_folder))

# Add our listing to Kodi.
xbmcplugin.addDirectoryItems(self.handle, listing, len(listing))
# Add a sort method for the virtual folder items
xbmcplugin.addSortMethod(self.handle, xbmcplugin.SORT_METHOD_NONE)
xbmcplugin.endOfDirectory(self.handle)

def list_radio_programs(self, station):
listing = []
for program in get_radio_programs(station):
title = program.get("title")
radio = program.get("radio")
program_url = program.get("@id")
list_item = xbmcgui.ListItem(label=title)
list_item.setInfo("music", {"title": title, "album": radio})
url = "{0}?action=audioprogram&program={1}".format(
self.url, program_url
)
is_folder = True
listing.append((url, list_item, is_folder))

# Add our listing to Kodi.
xbmcplugin.addDirectoryItems(self.handle, listing, len(listing))
# Add a sort method for the virtual folder items
xbmcplugin.addSortMethod(self.handle, xbmcplugin.SORT_METHOD_NONE)
xbmcplugin.endOfDirectory(self.handle)

def list_seasons(self, program):
seasons = get_program_seasons(program)
items = []
for season in seasons:
label = season.get("title")
url = season.get("@id")
list_item = xbmcgui.ListItem(label=label)
url = "{0}?action=audioseason&program={1}".format(self.url, url)
is_folder = True
items.append((url, list_item, is_folder))

# Add our listing to Kodi.
xbmcplugin.addDirectoryItems(self.handle, items, len(items))
# Add a sort method for the virtual folder items
xbmcplugin.addSortMethod(self.handle, xbmcplugin.SORT_METHOD_NONE)
xbmcplugin.endOfDirectory(self.handle)

def list_program_season_chapters(self, season):
chapters = get_program_season_chapters(season)
items = []
for chapter in chapters:
label = chapter.get("title")
url = chapter.get("@id")
list_item = xbmcgui.ListItem(label=label)
url = "{0}?action=audiochapter&program={1}".format(self.url, url)
is_folder = True
items.append((url, list_item, is_folder))

# Add our listing to Kodi.
xbmcplugin.addDirectoryItems(self.handle, items, len(items))
# Add a sort method for the virtual folder items
xbmcplugin.addSortMethod(self.handle, xbmcplugin.SORT_METHOD_NONE)
xbmcplugin.endOfDirectory(self.handle)

def list_program_audios(self, program):
audio = get_program_audios(program)
song_list = []

date = audio.get("date")
title = audio.get("title")
audio_url = audio.get("url")
label = u"{0} ({1})".format(date, title)
# create a list item using the song filename for the label
list_item = xbmcgui.ListItem(label=label)

url = "{0}?action=audioplay&program={1}".format(self.url, audio_url)
is_folder = False
song_list.append((url, list_item, is_folder))

# Add our listing to Kodi.
xbmcplugin.addDirectoryItems(self.handle, song_list, len(song_list))
# Add a sort method for the virtual folder items
xbmcplugin.addSortMethod(self.handle, xbmcplugin.SORT_METHOD_NONE)
xbmcplugin.endOfDirectory(self.handle)

def play_audio(self, path):
play_item = xbmcgui.ListItem(path=path)
# Pass the item to the Kodi player.
xbmcplugin.setResolvedUrl(self.handle, True, listitem=play_item)
25 changes: 25 additions & 0 deletions plugin.video.eitb/changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[B]3.0.0[/B]
- Works with new version of the API [erral]
[B]2.1.1[/B]
- Translate listings [erral]
[B]2.1.0[/B]
- New browsing options using program types [bipoza]
- Add latest added program list [bipoza]
[B]2.0.0[/B]
- Updates for Kodi Matrix (v19) [bipoza]
[B]1.0.5[/B]
- Fix plugin id on addon.xml
[B]1.0.4[/B]
- First version published on Kodi repository
[B]1.0.3[/B]
- Test version
[B]1.0.2[/B]
- Nothing changed yet.

[B]1.0.1[/B]
- Add install information and improve readme. [erral]

- Fixed python3 string formatting compatibility that created issues in Android [erral]

[B]1.0.0[/B]
- Initial release. [erral]
17 changes: 17 additions & 0 deletions plugin.video.eitb/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
MENU_ITEMS = [
{
"title_id": 32006,
"@id": "all_tvshows",
"icon": "/resources/tv_icon.png",
},
# {
# "title_id": 32007,
# "@id": "last_tvshows",
# "icon": "/resources/history_icon.png"
# },
{
"title_id": 32008,
"@id": "program-type-list",
"icon": "/resources/list_icon.png",
},
]
Binary file added plugin.video.eitb/fanart.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plugin.video.eitb/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plugin.video.eitb/resources/history_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9e06689

Please sign in to comment.