diff --git a/plugin.video.3cat/.github/workflows/release.yml b/plugin.video.3cat/.github/workflows/release.yml new file mode 100644 index 0000000000..3dd9e7394f --- /dev/null +++ b/plugin.video.3cat/.github/workflows/release.yml @@ -0,0 +1,45 @@ +name: Zip and Attach to Release + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Get repository name + id: repo-name + run: echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_OUTPUT + + - name: Get version number + id: version + uses: actions/github-script@v6 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const { owner, repo } = context.repo; + const release = await github.rest.repos.getRelease({ + owner, + repo, + release_id: context.payload.release.id + }); + return release.data.tag_name; + + - name: Create folder and zip content + run: | + mkdir ${{ steps.repo-name.outputs.REPO_NAME }} + rsync -av --exclude=${{ steps.repo-name.outputs.REPO_NAME }} . ${{ steps.repo-name.outputs.REPO_NAME }} + zip -r ${{ steps.repo-name.outputs.REPO_NAME }}-${{ steps.version.outputs.result }}.zip ${{ steps.repo-name.outputs.REPO_NAME }} + + - name: Upload release asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./${{ steps.repo-name.outputs.REPO_NAME }}-${{ steps.version.outputs.result }}.zip + asset_name: ${{ steps.repo-name.outputs.REPO_NAME }}-${{ steps.version.outputs.result }}.zip + asset_content_type: application/zip diff --git a/plugin.video.tv3.cat/LICENSE.txt b/plugin.video.3cat/LICENSE.txt similarity index 100% rename from plugin.video.tv3.cat/LICENSE.txt rename to plugin.video.3cat/LICENSE.txt diff --git a/plugin.video.3cat/README.md b/plugin.video.3cat/README.md new file mode 100644 index 0000000000..b678e7f0ac --- /dev/null +++ b/plugin.video.3cat/README.md @@ -0,0 +1,9 @@ +# plugin.video.3cat.cat +Kodi addon 3Cat. +Entertainment, news, sports, documentaries, etc from catalan television www.3cat.cat/3cat/ + +Complement per Kodi - XBMC. +Tota la programació de 3Cat. + + + diff --git a/plugin.video.tv3.cat/addon.py b/plugin.video.3cat/addon.py similarity index 67% rename from plugin.video.tv3.cat/addon.py rename to plugin.video.3cat/addon.py index d156731842..25d1167875 100644 --- a/plugin.video.tv3.cat/addon.py +++ b/plugin.video.3cat/addon.py @@ -1,22 +1,19 @@ -from __future__ import unicode_literals -from future import standard_library -standard_library.install_aliases() +import xbmc from builtins import str import sys import urllib.parse import xbmcplugin -import xbmc from resources.lib.ui.UI import UI +xbmc.log("plugin.video.3cat - addon.py") -xbmc.log("plugin.video.tv3.cat - addon.py") base_url = sys.argv[0] addon_handle = int(sys.argv[1]) xbmc.log(str(sys.argv[2][1:])) args = urllib.parse.parse_qs(sys.argv[2][1:]) -xbmc.log("plugin.video.tv3.cat - addon.py - args: ") +xbmc.log("plugin.video.3cat - addon.py - args: ") xbmc.log(str(args)) xbmcplugin.setContent(addon_handle, 'movies') @@ -24,10 +21,7 @@ mode = args.get('mode', None) url = args.get('url', ['']) - - ui = UI(base_url, addon_handle, args) - ui.run(mode, url) - + diff --git a/plugin.video.tv3.cat/addon.xml b/plugin.video.3cat/addon.xml similarity index 79% rename from plugin.video.tv3.cat/addon.xml rename to plugin.video.3cat/addon.xml index 921fabe89d..b74f30bf0d 100644 --- a/plugin.video.tv3.cat/addon.xml +++ b/plugin.video.3cat/addon.xml @@ -1,9 +1,10 @@ - + - - + + + video @@ -18,8 +19,8 @@ Toda la programación de TV3 a la carta.[CR]Las listas de los más vistos, destacados, programas ordenados de la A a la Z. [CR]Canales en directo: TV3cat, K33, Super3, 3/24, Esport3 ca GPL-2.0-or-later - https://github.com/jqandreu/plugin.video.tv3.cat - http://www.tv3.cat + https://github.com/mcr222/plugin.video.3cat + https://www.3cat.cat/3cat/ resources/icon.png resources/fanart.jpg diff --git a/plugin.video.3cat/changelog.txt b/plugin.video.3cat/changelog.txt new file mode 100644 index 0000000000..92bef9cd13 --- /dev/null +++ b/plugin.video.3cat/changelog.txt @@ -0,0 +1,2 @@ +v1.0.0 +- First version \ No newline at end of file diff --git a/plugin.video.tv3.cat/resources/__init__.py b/plugin.video.3cat/resources/__init__.py similarity index 100% rename from plugin.video.tv3.cat/resources/__init__.py rename to plugin.video.3cat/resources/__init__.py diff --git a/plugin.video.3cat/resources/fanart.jpg b/plugin.video.3cat/resources/fanart.jpg new file mode 100644 index 0000000000..14a1cb945b Binary files /dev/null and b/plugin.video.3cat/resources/fanart.jpg differ diff --git a/plugin.video.3cat/resources/icon.png b/plugin.video.3cat/resources/icon.png new file mode 100644 index 0000000000..2eb48299a2 Binary files /dev/null and b/plugin.video.3cat/resources/icon.png differ diff --git a/plugin.video.tv3.cat/resources/language/resource.language.ca_es/strings.po b/plugin.video.3cat/resources/language/resource.language.ca_es/strings.po similarity index 97% rename from plugin.video.tv3.cat/resources/language/resource.language.ca_es/strings.po rename to plugin.video.3cat/resources/language/resource.language.ca_es/strings.po index 2dfe72313e..ed1ca877df 100644 --- a/plugin.video.tv3.cat/resources/language/resource.language.ca_es/strings.po +++ b/plugin.video.3cat/resources/language/resource.language.ca_es/strings.po @@ -1,11 +1,11 @@ # Kodi Media Center language file # Addon Name: TV3cat -# Addon id: plugin.video.tv3.cat +# Addon id: plugin.video.3cat # Addon Provider: jqandreu msgid "" msgstr "" "Project-Id-Version: Kodi Addons\n" -"Report-Msgid-Bugs-To: https://github.com/jqandreu/plugin.video.tv3.cat/issues\n" +"Report-Msgid-Bugs-To: https://github.com/jqandreu/plugin.video.3cat/issues\n" "POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: jqandreu\n" diff --git a/plugin.video.tv3.cat/resources/language/resource.language.de_de/strings.po b/plugin.video.3cat/resources/language/resource.language.de_de/strings.po similarity index 97% rename from plugin.video.tv3.cat/resources/language/resource.language.de_de/strings.po rename to plugin.video.3cat/resources/language/resource.language.de_de/strings.po index 27aadd32c9..3819c79b9d 100644 --- a/plugin.video.tv3.cat/resources/language/resource.language.de_de/strings.po +++ b/plugin.video.3cat/resources/language/resource.language.de_de/strings.po @@ -1,11 +1,11 @@ # Kodi Media Center language file # Addon Name: TV3cat -# Addon id: plugin.video.tv3.cat +# Addon id: plugin.video.3cat # Addon Provider: jqandreu msgid "" msgstr "" "Project-Id-Version: Kodi Addons\n" -"Report-Msgid-Bugs-To: https://github.com/jqandreu/plugin.video.tv3.cat/issues\n" +"Report-Msgid-Bugs-To: https://github.com/jqandreu/plugin.video.3cat/issues\n" "POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Connum\n" diff --git a/plugin.video.tv3.cat/resources/language/resource.language.en_gb/strings.po b/plugin.video.3cat/resources/language/resource.language.en_gb/strings.po similarity index 97% rename from plugin.video.tv3.cat/resources/language/resource.language.en_gb/strings.po rename to plugin.video.3cat/resources/language/resource.language.en_gb/strings.po index 39ee30ed52..6bf0bca690 100644 --- a/plugin.video.tv3.cat/resources/language/resource.language.en_gb/strings.po +++ b/plugin.video.3cat/resources/language/resource.language.en_gb/strings.po @@ -1,11 +1,11 @@ # Kodi Media Center language file # Addon Name: TV3cat -# Addon id: plugin.video.tv3.cat +# Addon id: plugin.video.3cat # Addon Provider: jqandreu msgid "" msgstr "" "Project-Id-Version: Kodi Addons\n" -"Report-Msgid-Bugs-To: https://github.com/jqandreu/plugin.video.tv3.cat/issues\n" +"Report-Msgid-Bugs-To: https://github.com/jqandreu/plugin.video.3cat/issues\n" "POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: jqandreu\n" diff --git a/plugin.video.tv3.cat/resources/language/resource.language.es_es/strings.po b/plugin.video.3cat/resources/language/resource.language.es_es/strings.po similarity index 97% rename from plugin.video.tv3.cat/resources/language/resource.language.es_es/strings.po rename to plugin.video.3cat/resources/language/resource.language.es_es/strings.po index 22a420adf0..ba8843ab3e 100644 --- a/plugin.video.tv3.cat/resources/language/resource.language.es_es/strings.po +++ b/plugin.video.3cat/resources/language/resource.language.es_es/strings.po @@ -1,11 +1,11 @@ # Kodi Media Center language file # Addon Name: TV3cat -# Addon id: plugin.video.tv3.cat +# Addon id: plugin.video.3cat # Addon Provider: jqandreu msgid "" msgstr "" "Project-Id-Version: Kodi Addons\n" -"Report-Msgid-Bugs-To: https://github.com/jqandreu/plugin.video.tv3.cat/issues\n" +"Report-Msgid-Bugs-To: https://github.com/jqandreu/plugin.video.3cat/issues\n" "POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: jqandreu\n" diff --git a/plugin.video.tv3.cat/resources/language/resource.language.nb_no/strings.po b/plugin.video.3cat/resources/language/resource.language.nb_no/strings.po similarity index 97% rename from plugin.video.tv3.cat/resources/language/resource.language.nb_no/strings.po rename to plugin.video.3cat/resources/language/resource.language.nb_no/strings.po index 1e231676e0..eeaaf71d91 100644 --- a/plugin.video.tv3.cat/resources/language/resource.language.nb_no/strings.po +++ b/plugin.video.3cat/resources/language/resource.language.nb_no/strings.po @@ -1,11 +1,11 @@ # Kodi Media Center language file # Addon Name: TV3cat -# Addon id: plugin.video.tv3.cat +# Addon id: plugin.video.3cat # Addon Provider: jqandreu msgid "" msgstr "" "Project-Id-Version: Kodi Addons\n" -"Report-Msgid-Bugs-To: https://github.com/jqandreu/plugin.video.tv3.cat/issues\n" +"Report-Msgid-Bugs-To: https://github.com/jqandreu/plugin.video.3cat/issues\n" "POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: jrdfrncs\n" diff --git a/plugin.video.tv3.cat/resources/lib/__init__.py b/plugin.video.3cat/resources/lib/__init__.py similarity index 100% rename from plugin.video.tv3.cat/resources/lib/__init__.py rename to plugin.video.3cat/resources/lib/__init__.py diff --git a/plugin.video.tv3.cat/resources/lib/tv3cat/DirAZemisio.py b/plugin.video.3cat/resources/lib/tv3cat/DirAZemisio.py similarity index 100% rename from plugin.video.tv3.cat/resources/lib/tv3cat/DirAZemisio.py rename to plugin.video.3cat/resources/lib/tv3cat/DirAZemisio.py diff --git a/plugin.video.tv3.cat/resources/lib/tv3cat/DirAZtots.py b/plugin.video.3cat/resources/lib/tv3cat/DirAZtots.py similarity index 100% rename from plugin.video.tv3.cat/resources/lib/tv3cat/DirAZtots.py rename to plugin.video.3cat/resources/lib/tv3cat/DirAZtots.py diff --git a/plugin.video.3cat/resources/lib/tv3cat/Home.py b/plugin.video.3cat/resources/lib/tv3cat/Home.py new file mode 100644 index 0000000000..564b0388c7 --- /dev/null +++ b/plugin.video.3cat/resources/lib/tv3cat/Home.py @@ -0,0 +1,16 @@ +from resources.lib.video.FolderVideo import FolderVideo +from resources.lib.utils.Urls import url_coleccions, url_mesvist + + + +def getList(strings): + + #avuidestaquem = FolderVideo(strings.get('avuidestaquem'), "", "destaquem", "", "") + #noperdis = FolderVideo(strings.get('noperdis'), url_coleccions, "noperdis", "", "") + #mesvist = FolderVideo(strings.get('mesvist'), url_mesvist, "mesvist", "", "") + coleccions = FolderVideo(strings.get('coleccions'), "", "coleccions", "", "") + #programes = FolderVideo(strings.get('programes'), "", "programes", "", "") + #directe = FolderVideo(strings.get('directe'), "", "directe", "", "") + #cercar = FolderVideo(strings.get('cercar'), "", "cercar", "", "") + + return [coleccions] \ No newline at end of file diff --git a/plugin.video.tv3.cat/resources/lib/tv3cat/Images.py b/plugin.video.3cat/resources/lib/tv3cat/Images.py similarity index 100% rename from plugin.video.tv3.cat/resources/lib/tv3cat/Images.py rename to plugin.video.3cat/resources/lib/tv3cat/Images.py diff --git a/plugin.video.tv3.cat/resources/lib/tv3cat/Sections.py b/plugin.video.3cat/resources/lib/tv3cat/Sections.py similarity index 100% rename from plugin.video.tv3.cat/resources/lib/tv3cat/Sections.py rename to plugin.video.3cat/resources/lib/tv3cat/Sections.py diff --git a/plugin.video.tv3.cat/resources/lib/tv3cat/TV3Strings.py b/plugin.video.3cat/resources/lib/tv3cat/TV3Strings.py similarity index 100% rename from plugin.video.tv3.cat/resources/lib/tv3cat/TV3Strings.py rename to plugin.video.3cat/resources/lib/tv3cat/TV3Strings.py diff --git a/plugin.video.3cat/resources/lib/tv3cat/TV3cat.py b/plugin.video.3cat/resources/lib/tv3cat/TV3cat.py new file mode 100644 index 0000000000..525d6a8d9b --- /dev/null +++ b/plugin.video.3cat/resources/lib/tv3cat/TV3cat.py @@ -0,0 +1,373 @@ +from __future__ import division + +from builtins import object +from collections import defaultdict + +from bs4 import BeautifulSoup + + +from resources.lib.tv3cat import DirAZemisio +from resources.lib.tv3cat import DirAZtots +from resources.lib.tv3cat import Home +from resources.lib.tv3cat.Images import Images +from resources.lib.tv3cat import Sections +from resources.lib.utils import Urls +from resources.lib.utils.Urls import url_base +from resources.lib.video.FolderVideo import FolderVideo +from resources.lib.video.Video import Video +from resources.lib.tv3cat.TV3Strings import TV3Strings +from resources.lib.utils.Utils import * + + +class TV3cat(object): + def __init__(self, addon_path, addon): + xbmc.log("plugin.video.3cat classe TV3cat - init() ") + self.strs = TV3Strings(addon) + self.images = Images(addon_path) + self.addon_path = addon_path + + # mode = None + def listHome(self): + xbmc.log("plugin.video.3cat classe Tv3cat - listHome() ") + + return Home.getList(self.strs) + + def getJsonDataNextData(self, url): + link = getHtml(url) + + if link: + soup = BeautifulSoup(link, "html.parser") + + script_tag = soup.find('script', id='__NEXT_DATA__') + if script_tag: + xbmc.log("plugin.video.3cat - found script") + + # Find all items with 'nombonic' and 'id' + # Extract the JSON content from the script tag + json_content = script_tag.string + # print(json_content) + # Extract the data from the JSON content + data = json.loads(json_content) + + # Extract the required information + return data + + return [] + + def getTotsProgrames(self): + data = self.getJsonDataNextData(Urls.url_coleccions) + if not data: + return [] + # Extract the required information + return data['props']['pageProps']['layout']['structure'][4]['children'][0]['finalProps']['items'] + + def getProgramaId(self, titolPrograma): + data = self.getJsonDataNextData(Urls.url_base + titolPrograma) + if not data: + return [] + + return data['props']['pageProps']['layout']['structure'][3]['children'][0]['finalProps']['programaId'] + + # mode = coleccions + def listProgrames(self, nomCategoria): + xbmc.log("plugin.video.3cat - programes per categoria " + nomCategoria) + lFolderVideos = [] + categories = self.getTotsProgrames() + for categoria in categories: + if nomCategoria == categoria['valor']: + xbmc.log("plugin.video.3cat - Found categoria " + nomCategoria) + items = categoria['item'] + for item in items: + if 'nombonic' in item and 'id' in item: + xbmc.log("plugin.video.3cat - element " + str(item)) + titol = item['nombonic'] + img = self.extractImageIfAvailable(item, "IMG_POSTER") + foldVideo = FolderVideo(titol, titol, 'getTemporades', img, img) + lFolderVideos.append(foldVideo) + + return lFolderVideos + + return lFolderVideos + + + # mode = coleccions + def listColeccions(self): + xbmc.log("plugin.video.3cat - listColeccions") + lFolderVideos = [] + + for categoria in self.getTotsProgrames(): + print(categoria) + nom_categoria = categoria['valor'] + xbmc.log("plugin.video.3cat - Found categoria " + nom_categoria) + foldVideo = FolderVideo(nom_categoria, nom_categoria, 'getProgrames') + lFolderVideos.append(foldVideo) + + return lFolderVideos + + + # mode = programes + def dirSections(self): + return Sections.getList(self.strs) + + # mode = directe + def listDirecte(self): + xbmc.log("-----------------listDirecte--------------------") + lVideos = [] + + data = getDataVideo(Urls.url_arafem) + + if data: + c = data.get('canal', None) + + if c: + + arafemtv3 = '' + arafem33 = '' + arafemesp3 = '' + arafem324 = '' + arafemtv3_sinop = '' + arafem33_sinop = '' + arafemesp3_sinop = '' + arafem324_sinop = '' + + i = 0 + while i < 5: + nameChannel = c[i].get('ara_fem', {}).get('codi_canal', None) + + if nameChannel == 'tv3': + arafemtv3 = c[i].get('ara_fem', {}).get('titol_programa', None) + arafemtv3_sinop = c[i].get('ara_fem', {}).get('sinopsi', None) + if nameChannel == 'cs3' or nameChannel == '33d': + arafem33 = c[i].get('ara_fem', {}).get('titol_programa', None) + arafem33_sinop = c[i].get('ara_fem', {}).get('sinopsi', None) + if nameChannel == 'esport3': + arafemesp3 = c[i].get('ara_fem', {}).get('titol_programa', None) + arafemesp3_sinop = c[i].get('ara_fem', {}).get('sinopsi', None) + if nameChannel == '324': + arafem324 = c[i].get('ara_fem', {}).get('titol_programa', None) + arafem324_sinop = c[i].get('ara_fem', {}).get('sinopsi', None) + + i = i + 1 + + infolabelstv3 = {} + infolabels324 = {} + infolabels33 = {} + infolabelsesp3 = {} + + if arafemtv3: + infolabelstv3['title'] = arafemtv3 + infotv3 = '[B]' + arafemtv3 + '[/B]' + '[CR]' + if arafemtv3_sinop: + if type(arafemtv3) is int or type(arafemtv3) is float: + arafemtv3 = str(arafemtv3) + infotv3 = infotv3 + arafemtv3_sinop + + infolabelstv3['plot'] = infotv3 + + if arafem33: + infolabels33['title'] = arafem33 + info33 = '[B]' + arafem33 + '[/B]' + '[CR]' + if arafem33_sinop: + if type(arafem33) is int or type(arafem33) is float: + arafem33 = str(arafem33) + info33 = info33 + arafem33_sinop + + infolabels33['plot'] = info33 + + if arafemesp3: + infolabelsesp3['title'] = arafemesp3 + infoesp3 = '[B]' + arafemesp3 + '[/B]' + '[CR]' + if arafemesp3_sinop: + if type(arafemesp3) is int or type(arafemesp3) is float: + arafemesp3 = str(arafemesp3) + infoesp3 = infoesp3 + arafemesp3_sinop + + infolabelsesp3['plot'] = infoesp3 + + if arafem324: + infolabels324['title'] = arafem324 + info324 = '[B]' + arafem324 + '[/B]' + '[CR]' + if arafem324_sinop: + if type(arafem324) is int or type(arafem324) is float: + arafem324 = str(arafem324) + info324 = info324 + arafem324_sinop + + infolabels324['plot'] = info324 + + tv3Directe = Video(self.strs.get('tv3'), self.images.thumb_tv3, self.images.thumb_tv3, infolabelstv3, Urls.url_directe_tv3, "") + c324Directe = Video(self.strs.get('canal324'), self.images.thumb_tv3, self.images.thumb_tv3, infolabels324, Urls.url_directe_324, "") + c33s3Directe = Video(self.strs.get('c33super3'), self.images.thumb_tv3, self.images.thumb_tv3, infolabels33, Urls.url_directe_c33s3, "") + sps3Directe = Video(self.strs.get('esport3'), self.images.thumb_tv3, self.images.thumb_tv3, infolabelsesp3, Urls.url_directe_esport3, "") + + tv3DirecteInt = Video(self.strs.get('tv3_int'), self.images.thumb_tv3, self.images.thumb_tv3, infolabelstv3, Urls.url_directe_tv3_int, "") + c324DirecteInt = Video(self.strs.get('canal324_int'), self.images.thumb_tv3, self.images.thumb_tv3, infolabels324, Urls.url_directe_324_int, "") + c33s3DirecteInt = Video(self.strs.get('c33super3_int'), self.images.thumb_tv3, self.images.thumb_tv3, infolabels33, Urls.url_directe_c33s3_int, "") + sps3DirecteInt = Video(self.strs.get('esport3_int'), self.images.thumb_tv3, self.images.thumb_tv3, infolabelsesp3, Urls.url_directe_esport3_int, "") + + lVideos = [tv3Directe, c33s3Directe, c324Directe, sps3Directe, tv3DirecteInt, c33s3DirecteInt, c324DirecteInt, sps3DirecteInt] + + result = [None] * 2 + result[0] = lVideos + return result + + def getProgramaData(self, programaId): + apiUrl = ("https://api.3cat.cat/videos?version=2.0&_format=json&items_pagina=1000&capitol=1|&tipus_contingut=PPD&ordre=capitol&idioma=PU_CATALA&programatv_id={}&perfil=pc" + .format(programaId)) + + with urllib.request.urlopen(apiUrl) as response: + data = response.read() + json_data = json.loads(data) + return json_data['resposta']['items']['item'] + + #mode getTemporades + def getListTemporades(self, programaTitol): + xbmc.log("plugin.video.3cat llista temporades " + programaTitol) + lFolderVideos = [] + programaId = self.getProgramaId(programaTitol) + items = self.getProgramaData(programaId) + + # Set to store unique temporades + unique_temporades = set() + + # Count items without temporades + sense_temporada_count = 0 + + for item in items: + if item.get('temporades'): + # Only consider the first temporada + first_temporada = item['temporades'][0]['desc'] + unique_temporades.add(first_temporada) + else: + sense_temporada_count += 1 + + # Add "Sense Temporada" if there are items without temporades + if sense_temporada_count > 0: + unique_temporades.add("Sense Temporada") + + for temporada in unique_temporades: + foldVideo = FolderVideo(temporada, str(programaId) + "_" + str(temporada), 'getlistvideos', '', '') + lFolderVideos.append(foldVideo) + + return lFolderVideos + + def extractImageIfAvailable(self, item, keyimatge): + # Extract image links if available + if 'imatges' in item and isinstance(item['imatges'], list): + for image in item['imatges']: + if 'text' in image and image['text'].startswith('http') \ + and image['rel_name'] == keyimatge: + return image['text'] + + # mode = getlistvideos + def getListVideos(self, url): + xbmc.log("plugin.video.3cat - get list videos " + str(url)) + (programaId, target_temporada) = url.split('_') + lVideos = [] + matching_items = [] + + for item in self.getProgramaData(programaId): + if item.get('temporades'): + # Only consider the first temporada + first_temporada = item['temporades'][0]['desc'] + if first_temporada == target_temporada: + matching_items.append(item) + elif target_temporada == "Sense Temporada": + matching_items.append(item) + + # Display results + if matching_items: + print(f"Items matching temporada '{target_temporada}':") + for item in matching_items: + img = self.extractImageIfAvailable(item, "KEYVIDEO") + video = Video(item['titol'], img, img, item.get('entradeta'), item['id'], item['durada']) + lVideos.append(video) + else: + print(f"No items found for temporada '{target_temporada}'") + + return lVideos + + + def getVideo(self, data): + linkvideo = None + media = data.get('media', {}) + + if type(media) is list and len(media) > 0: + media_dict = media[0] + linkvideo = media_dict.get('url', None) + else: + linkvideo = media.get('url', None) + + if linkvideo != None: + if type(linkvideo) is list and len(linkvideo) > 0: + linkvideo_item = linkvideo[0] + urlVideo = linkvideo_item.get('file', None) + + titol = data.get('informacio', {}).get('titol', None) + image = data.get('imatges', {}).get('url', None) + descripcio = data.get('informacio', {}).get('descripcio', None) + programa = data.get('informacio', {}).get('programa', None) + capitol = data.get('informacio', {}).get('capitol', None) + tematica = data.get('informacio', {}).get('tematica', {}).get('text', None) + data_emisio = data.get('informacio', {}).get('data_emissio', {}).get('text', None) + milisec = data.get('informacio', {}).get('durada', {}).get('milisegons', None) + durada = "" + + if milisec != None: + durada = milisec // 1000 + + + if descripcio == None: + descripcio = '' + else: + descripcio = descripcio.replace('
', '') + + header = "" + if programa != None: + if type(programa) is int or type(programa) is float: + programa = str(programa) + header = '[B]' + programa + '[/B]' + '[CR]' + + infolabels = {} + if data_emisio != None: + dt = data_emisio[0:10] + year = data_emisio[6:10] + infolabels['aired'] = dt + infolabels['year'] = year + header = header + dt + '[CR]' + + descripcio = header + descripcio + + if titol != None: + infolabels['title'] = titol + + + if capitol != None: + infolabels['episode'] = capitol + + + if descripcio != None: + infolabels['plot'] = descripcio + + if tematica != None: + infolabels['genre'] = tematica + + video = Video(titol, image, image, infolabels, urlVideo, durada ) + + return video + + else: + return None + + #mode = cercar + def search(self): + + keyboard = xbmc.Keyboard('', self.strs.get('cercar')) + keyboard.doModal() + if keyboard.isConfirmed() and keyboard.getText(): + search_string = keyboard.getText().replace(" ", "+") + url = "http://www.ccma.cat/tv3/alacarta/cercador/?items_pagina=15&profile=videos&text=" + search_string + + lVideos = self.getListVideos(url, True) + + return lVideos + diff --git a/plugin.video.3cat/resources/lib/tv3cat/TestHtml.py b/plugin.video.3cat/resources/lib/tv3cat/TestHtml.py new file mode 100644 index 0000000000..d967c193f5 --- /dev/null +++ b/plugin.video.3cat/resources/lib/tv3cat/TestHtml.py @@ -0,0 +1,31 @@ +import json + +from resources.lib.tv3cat.TV3cat import TV3cat +import urllib.request, urllib.parse, urllib.error +#un munt de testos de les diferents funcions usades + +tv3 = TV3cat("", "") +#tv3.listColeccions() +tv3.listProgrames("A") + +# temporades = tv3.getListTemporades('200164279') +# print(len(temporades)) +# for temp in temporades: +# print(temp.url) + +#capitols = tv3.getListVideos("200164279_17a Temporada") +#print(len(capitols)) +#for cap in capitols: +# print(cap.title + " " + cap.title + " " + str(cap.iconImage)) + +#videos = tv3.getListVideos("https://www.3cat.cat/3cat/bricoheroes/capitols/temporada/2/") +#print(len(videos)) +#print(videos[0]) +# videoId = 6176980 +# apiJsonUrl = "https://api-media.3cat.cat/pvideo/media.jsp?media=video&versio=vast&idint={}&profile=pc_3cat&format=dm".format( +# videoId) +# print(apiJsonUrl) +# with urllib.request.urlopen(apiJsonUrl) as response: +# data = response.read() +# json_data = json.loads(data) +# print(json_data['media']['url'][0]['file']) diff --git a/plugin.video.tv3.cat/resources/lib/tv3cat/__init__.py b/plugin.video.3cat/resources/lib/tv3cat/__init__.py similarity index 100% rename from plugin.video.tv3.cat/resources/lib/tv3cat/__init__.py rename to plugin.video.3cat/resources/lib/tv3cat/__init__.py diff --git a/plugin.video.3cat/resources/lib/ui/UI.py b/plugin.video.3cat/resources/lib/ui/UI.py new file mode 100644 index 0000000000..7681383b31 --- /dev/null +++ b/plugin.video.3cat/resources/lib/ui/UI.py @@ -0,0 +1,184 @@ +import json +from builtins import str +from builtins import object + +import urllib.request, urllib.parse, urllib.error + +from resources.lib.utils.Utils import buildUrl +from resources.lib.tv3cat.TV3cat import TV3cat +import xbmcaddon +import xbmcplugin +import xbmcgui +import xbmc +import xbmcvfs +import urllib.parse + +from resources.lib.video.Video import Video + +PROTOCOL = 'mpd' +DRM = 'com.widevine.alpha' +LICENSE_URL = 'https://cwip-shaka-proxy.appspot.com/no_auth' + + +class UI(object): + + def __init__(self, base_url, addon_handle, args): + xbmc.log("plugin.video.3cat classe UI - start init() ") + addon = xbmcaddon.Addon() + addon_path = xbmcvfs.translatePath(addon.getAddonInfo('path')) + self.tv3 = TV3cat(addon_path, addon) + self.base_url = base_url + self.addon_handle = addon_handle + self.args = args + self.mode = args.get('mode', None) + self.url = args.get('url', ['']) + xbmc.log("plugin.video.3cat classe UI - finish init()") + + + def run(self, mode, url): + xbmc.log("plugin.video.3cat classe UI - run() mode = " + str(mode) + ", url " + str(url)) + + if mode == None: + xbmc.log("plugin.video.3cat classe UI - mode = None") + lFolder = self.tv3.listHome() + + if len(lFolder) > 0: + self.listFolder(lFolder) + else: + xbmc.log("plugin.video.3cat - UI.run() Home - No existeixen elements") + + elif mode[0] == 'programes': + + lFolder = self.tv3.dirSections() + + if len(lFolder) > 0: + self.listFolder(lFolder) + else: + xbmc.log("plugin.video.3cat - UI.run() programes - No existeixen elements") + + elif mode[0] == 'sections': + + lFolder = self.tv3.programsSections(url[0]) + + if len(lFolder) > 0: + self.listFolder(lFolder) + else: + xbmc.log("plugin.video.3cat - UI.run() sections - No existeixen elements") + + elif mode[0] == 'directe': + + lVideos = self.tv3.listDirecte() + self.listVideos(lVideos) + + elif mode[0] == 'cercar': + + lVideos = self.tv3.search() + + if len(lVideos) > 0: + self.listVideos(lVideos) + else: + xbmc.log("plugin.video.3cat - UI.run() cercar - No s'ha trobat cap video") + + + elif mode[0] == 'getlistvideos': + lVideos = self.tv3.getListVideos(url[0]) + self.listVideos(lVideos) + + elif mode[0] == 'getProgrames': + xbmc.log("plugin.video.3cat - Programes") + lFolder = self.tv3.listProgrames(url[0]) + self.listFolder(lFolder) + + elif mode[0] == 'getTemporades': + xbmc.log("plugin.video.3cat - Temporades") + lFolder = self.tv3.getListTemporades(url[0]) + self.listFolder(lFolder) + + elif mode[0] == 'coleccions': + xbmc.log("plugin.video.3cat - Coleccions") + lFolder = self.tv3.listColeccions() + self.listFolder(lFolder) + + elif mode[0] == 'playVideo': + self.playVideo(url[0]) + + def listFolder(self, lFolderVideos): + xbmc.log("plugin.video.3cat classe UI - listFolder") + for folder in lFolderVideos: + + mode = folder.mode + name = folder.name + url = folder.url + iconImage = folder.iconImage + thumbImage = folder.thumbnailImage + + urlPlugin = buildUrl({'mode': mode, 'url': url}, self.base_url) + liz = xbmcgui.ListItem(name) + liz.setInfo(type="Video", infoLabels={"title": name}) + liz.setArt({'thumb': thumbImage, 'icon' : iconImage}) + + xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=urlPlugin, listitem=liz, isFolder=True) + xbmcplugin.endOfDirectory(self.addon_handle) + + def listVideos(self, lVideos): + xbmc.log("plugin.video.3cat - UI - listVideos - Numero videos: " + str(len(lVideos))) + + for video in lVideos: + # Create a list item with a text label + list_item = xbmcgui.ListItem(label=video.title) + # Set graphics (thumbnail, fanart, banner, poster, landscape etc.) for the list item. + # Here we use only poster for simplicity's sake. + # In a real-life plugin you may need to set multiple image types. + list_item.setArt({'poster': video.iconImage}) + list_item.setProperty('IsPlayable', 'true') + # Set additional info for the list item via InfoTag. + # 'mediatype' is needed for skin to display info for this ListItem correctly. + info_tag = list_item.getVideoInfoTag() + info_tag.setMediaType('movie') + info_tag.setTitle(video.title) + info_tag.setPlot(video.information) + # Set 'IsPlayable' property to 'true'. + + url = video.url + # Add the list item to a virtual Kodi folder. + # is_folder = False means that this item won't open any sub-list. + is_folder = False + # Add our item to the Kodi virtual folder listing. + xbmc.log("plugin.video.3cat - UI - directory item " + str(url)) + urlPlugin = buildUrl({'mode': 'playVideo', 'url': url}, self.base_url) + + xbmcplugin.addDirectoryItem(self.addon_handle, urlPlugin, list_item, is_folder) + # Add sort methods for the virtual folder items + xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE) + xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_VIDEO_YEAR) + # Finish creating a virtual folder. + xbmcplugin.endOfDirectory(self.addon_handle) + + def playVideo(self,videoId): + xbmc.log("plugin.video.3cat -UI - playVideo " + str(videoId)) + + apiJsonUrl = "https://api-media.3cat.cat/pvideo/media.jsp?media=video&versio=vast&idint={}&profile=pc_3cat&format=dm".format( + videoId) + xbmc.log("plugin.video.3cat -UI - playVideo apijson url" + str(apiJsonUrl)) + streamMPDFile = "" + with urllib.request.urlopen(apiJsonUrl) as response: + data = response.read() + json_data = json.loads(data) + streamMPDFile = json_data['media']['url'][0]['file'] + + xbmc.log("plugin.video.3cat -UI - playVideo mpd file" + str(streamMPDFile)) + + from inputstreamhelper import Helper # pylint: disable=import-outside-toplevel + + is_helper = Helper(PROTOCOL, drm=DRM) + if is_helper.check_inputstream(): + play_item = xbmcgui.ListItem(path=streamMPDFile) + play_item.setProperty('inputstream', 'inputstream.adaptive') + play_item.setProperty('inputstream.adaptive.stream_headers', + 'User-Agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36') + play_item.setProperty('inputstream.adaptive.manifest_update_parameter', 'full') + play_item.setProperty('inputstream.adaptive.manifest_update_interval', '10') + play_item.setProperty('inputstream.adaptive.manifest_type', PROTOCOL) + play_item.setProperty('inputstream.adaptive.license_type', DRM) + play_item.setProperty('inputstream.adaptive.license_key', LICENSE_URL + '||R{SSM}|') + xbmcplugin.setResolvedUrl(handle=self.addon_handle, succeeded=True, listitem=play_item) \ No newline at end of file diff --git a/plugin.video.tv3.cat/resources/lib/ui/__init__.py b/plugin.video.3cat/resources/lib/ui/__init__.py similarity index 100% rename from plugin.video.tv3.cat/resources/lib/ui/__init__.py rename to plugin.video.3cat/resources/lib/ui/__init__.py diff --git a/plugin.video.tv3.cat/resources/lib/utils/Urls.py b/plugin.video.3cat/resources/lib/utils/Urls.py similarity index 92% rename from plugin.video.tv3.cat/resources/lib/utils/Urls.py rename to plugin.video.3cat/resources/lib/utils/Urls.py index 5ea4d50327..9725a4eb6a 100644 --- a/plugin.video.tv3.cat/resources/lib/utils/Urls.py +++ b/plugin.video.3cat/resources/lib/utils/Urls.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -url_base = 'http://www.ccma.cat' +url_base = 'https://www.3cat.cat/3cat/' url_alacarta = 'http://www.ccma.cat/tv3/alacarta/' -url_coleccions = 'http://www.ccma.cat/tv3/alacarta/coleccions/' +url_coleccions = 'https://www.3cat.cat/3cat/tot-cataleg/tot/' url_mesvist = 'http://www.ccma.cat/tv3/alacarta/mes-vist/' url_datavideos = 'http://dinamics.ccma.cat/pvideo/media.jsp?media=video&version=0s&idint=' url_programes_emisio = 'http://www.ccma.cat/tv3/alacarta/programes' diff --git a/plugin.video.tv3.cat/resources/lib/utils/Utils.py b/plugin.video.3cat/resources/lib/utils/Utils.py similarity index 89% rename from plugin.video.tv3.cat/resources/lib/utils/Utils.py rename to plugin.video.3cat/resources/lib/utils/Utils.py index 360f243307..b9a5185da4 100644 --- a/plugin.video.tv3.cat/resources/lib/utils/Utils.py +++ b/plugin.video.3cat/resources/lib/utils/Utils.py @@ -1,8 +1,5 @@ -from future import standard_library -standard_library.install_aliases() from builtins import str import urllib.request, urllib.parse, urllib.error -import urllib.request, urllib.error, urllib.parse import json import xbmcgui import xbmc @@ -11,6 +8,11 @@ def buildUrl(query, base_url): return base_url + '?' + urllib.parse.urlencode(query) +def find_key_by_value(json_data, target_key): + for key, value in json_data.items(): + if key == target_key: + return key, value + return None, None def getHtml(url): try: diff --git a/plugin.video.tv3.cat/resources/lib/utils/__init__.py b/plugin.video.3cat/resources/lib/utils/__init__.py similarity index 100% rename from plugin.video.tv3.cat/resources/lib/utils/__init__.py rename to plugin.video.3cat/resources/lib/utils/__init__.py diff --git a/plugin.video.tv3.cat/resources/lib/video/FolderVideo.py b/plugin.video.3cat/resources/lib/video/FolderVideo.py similarity index 57% rename from plugin.video.tv3.cat/resources/lib/video/FolderVideo.py rename to plugin.video.3cat/resources/lib/video/FolderVideo.py index 519e58b04d..6a4c029e20 100644 --- a/plugin.video.tv3.cat/resources/lib/video/FolderVideo.py +++ b/plugin.video.3cat/resources/lib/video/FolderVideo.py @@ -1,11 +1,13 @@ from builtins import object +import xbmc + class FolderVideo(object): - def __init__(self, name, url, mode, iconImage, thumbnaiImage): + def __init__(self, name, url, mode, iconImage ="", thumbnaiImage=""): """ :rtype: object """ - + xbmc.log("plugin.video.3cat Creant folder video " + str(name) + ", " + str(url) + ", " + str(mode)) self.name = name self.url = url self.mode = mode diff --git a/plugin.video.tv3.cat/resources/lib/video/Video.py b/plugin.video.3cat/resources/lib/video/Video.py similarity index 78% rename from plugin.video.tv3.cat/resources/lib/video/Video.py rename to plugin.video.3cat/resources/lib/video/Video.py index 1708bf804a..9a5cb15a90 100644 --- a/plugin.video.tv3.cat/resources/lib/video/Video.py +++ b/plugin.video.3cat/resources/lib/video/Video.py @@ -1,8 +1,12 @@ from builtins import object + +import xbmc + + class Video(object): def __init__(self, title, iconImage, thumbnailImage, information, url, durada): - + xbmc.log("plugin.video.3cat - video " + str(title) + ", " + str(url)) self.title = title self.iconImage = iconImage self.thumbnailImage = thumbnailImage diff --git a/plugin.video.tv3.cat/resources/lib/video/__init__.py b/plugin.video.3cat/resources/lib/video/__init__.py similarity index 100% rename from plugin.video.tv3.cat/resources/lib/video/__init__.py rename to plugin.video.3cat/resources/lib/video/__init__.py diff --git a/plugin.video.tv3.cat/resources/media/324_thumbnail.png b/plugin.video.3cat/resources/media/324_thumbnail.png similarity index 100% rename from plugin.video.tv3.cat/resources/media/324_thumbnail.png rename to plugin.video.3cat/resources/media/324_thumbnail.png diff --git a/plugin.video.tv3.cat/resources/media/c33-super3_thumbnail.png b/plugin.video.3cat/resources/media/c33-super3_thumbnail.png similarity index 100% rename from plugin.video.tv3.cat/resources/media/c33-super3_thumbnail.png rename to plugin.video.3cat/resources/media/c33-super3_thumbnail.png diff --git a/plugin.video.tv3.cat/resources/media/esports3_thumbnail.png b/plugin.video.3cat/resources/media/esports3_thumbnail.png similarity index 100% rename from plugin.video.tv3.cat/resources/media/esports3_thumbnail.png rename to plugin.video.3cat/resources/media/esports3_thumbnail.png diff --git a/plugin.video.tv3.cat/resources/media/tv3_thumbnail.png b/plugin.video.3cat/resources/media/tv3_thumbnail.png similarity index 100% rename from plugin.video.tv3.cat/resources/media/tv3_thumbnail.png rename to plugin.video.3cat/resources/media/tv3_thumbnail.png diff --git a/plugin.video.tv3.cat/README.md b/plugin.video.tv3.cat/README.md deleted file mode 100644 index 9b73fb3a0c..0000000000 --- a/plugin.video.tv3.cat/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# plugin.video.tv3.cat -Kodi addon TV3cat. -Entertainment, news, sports, documentaries, etc from catalan television www.tv3.cat - -Complement per Kodi - XBMC. -Tota la programació de TV3 a la carta. Llistes dels programes Més vistos, Destacats, No t'ho perdis, etc. - - - diff --git a/plugin.video.tv3.cat/changelog.txt b/plugin.video.tv3.cat/changelog.txt deleted file mode 100644 index 058c70ca96..0000000000 --- a/plugin.video.tv3.cat/changelog.txt +++ /dev/null @@ -1,91 +0,0 @@ - -v1.4.9 -- Fixed server changes - -v1.4.8 -- Adapted to Kodi 19 -- Fixed errors - -v1.4.7 -- Fixed direct channels urls - -1.4.6 -- Fixed server changes - -1.4.5 -- Fixed server changes - -v1.4.4 -- Fixed error in Libreelec with import lib2to3 script. Deleted old_div - -v1.4.3 -- Code redesigned and added Python 2/3 compatibility - -v1.4.2 -- Fixed website changes. Changed live urls channels - -v1.4.1 -- Fixed website changes. Fixed errors in "Today featured" and "Colecctions" - -v1.4.0 -- Corregits canvis al website - --Fixed website changes - -v1.3.9 -- Canviada reproducció de videos a HD -- Afegida traducció en alemany gràcies a Connum - -- Changed videos playback to HD -- Added german translation thanks to Connum - -v1.3.8 -- Corregits canvis al website -- Fixed website changes - -v1.3.7 -- Afegides urls per l'emissió internacional dels canals en directe. Gràcies a jrdfrncs -- Afegida traducció del noruec. Gràcies a jrdfrncs -- Correcció d'errors - -- Added urls to international broadcast of live channels. Thanks to jrdfrncs -- Added norwegian translation. Thanks to jrdfrncs -- Fixed minor errors - -v1.3.6 -- Fixed website changes -- Improved efficiency in listing videos - -v1.3.5 -- Improved video info -- Updated python version -- Added new section Coleccions - -v1.3.4 -- Fixed website changes - -v1.3.3 -- Fixed website changes -- Added search function -- Added dependency on BeautifulSoup -- Minor improvements - -v1.3.2 -- Fixed website changes - -v1.3.1 -- Fixes due to website changes - -v1.3.0 -- Fixed minor errors - -v1.2.9 -- Fixed minor errors - -v1.2.8 -- Added info on live channels - -v1.2.7 -- Initial version - - diff --git a/plugin.video.tv3.cat/resources/fanart.jpg b/plugin.video.tv3.cat/resources/fanart.jpg deleted file mode 100644 index 15064988a7..0000000000 Binary files a/plugin.video.tv3.cat/resources/fanart.jpg and /dev/null differ diff --git a/plugin.video.tv3.cat/resources/icon.png b/plugin.video.tv3.cat/resources/icon.png deleted file mode 100644 index 2c86a837e7..0000000000 Binary files a/plugin.video.tv3.cat/resources/icon.png and /dev/null differ diff --git a/plugin.video.tv3.cat/resources/lib/tv3cat/Home.py b/plugin.video.tv3.cat/resources/lib/tv3cat/Home.py deleted file mode 100644 index f999d00aa4..0000000000 --- a/plugin.video.tv3.cat/resources/lib/tv3cat/Home.py +++ /dev/null @@ -1,18 +0,0 @@ -from resources.lib.video.FolderVideo import FolderVideo -from resources.lib.utils.Urls import url_coleccions, url_mesvist - - - -def getList(strings): - - avuidestaquem = FolderVideo(strings.get('avuidestaquem'), "", "destaquem", "", "") - #noperdis = FolderVideo(strings.get('noperdis'), url_coleccions, "noperdis", "", "") - mesvist = FolderVideo(strings.get('mesvist'), url_mesvist, "mesvist", "", "") - coleccions = FolderVideo(strings.get('coleccions'), "", "coleccions", "", "") - programes = FolderVideo(strings.get('programes'), "", "programes", "", "") - directe = FolderVideo(strings.get('directe'), "", "directe", "", "") - cercar = FolderVideo(strings.get('cercar'), "", "cercar", "", "") - - list = [avuidestaquem, mesvist, coleccions, programes, directe, cercar] - - return list \ No newline at end of file diff --git a/plugin.video.tv3.cat/resources/lib/tv3cat/TV3cat.py b/plugin.video.tv3.cat/resources/lib/tv3cat/TV3cat.py deleted file mode 100644 index 54d38e97dd..0000000000 --- a/plugin.video.tv3.cat/resources/lib/tv3cat/TV3cat.py +++ /dev/null @@ -1,694 +0,0 @@ -from __future__ import division - -from builtins import object -import re -import xbmc -import urllib.parse -from bs4 import BeautifulSoup - - -from resources.lib.tv3cat import DirAZemisio -from resources.lib.tv3cat import DirAZtots -from resources.lib.tv3cat import Home -from resources.lib.tv3cat.Images import Images -from resources.lib.tv3cat import Sections -from resources.lib.utils import Urls -from resources.lib.video.FolderVideo import FolderVideo -from resources.lib.video.Video import Video -from resources.lib.tv3cat.TV3Strings import TV3Strings -from resources.lib.utils.Utils import * - - -class TV3cat(object): - def __init__(self, addon_path, addon): - self.strs = TV3Strings(addon) - self.images = Images(addon_path) - self.addon_path = addon_path - - xbmc.log("plugin.video.tv3.cat classe TV3cat - init() ") - - # mode = None - def listHome(self): - xbmc.log("plugin.video.tv3.cat classe Tv3cat - listHome() ") - - return Home.getList(self.strs) - - # mode = destaquem - def listDestaquem(self): - xbmc.log("plugin.video.tv3.cat classe Tv3cat - listDestaquem() ") - html_destacats = getHtml(Urls.url_alacarta) - - lVideos = [] - - if html_destacats: - - soup = BeautifulSoup(html_destacats, "html.parser") - dest = None - - try: - - destacats = soup.findAll("article", {"class": re.compile("M-destacat")}) - - - destacats2 = soup.findAll("div", {"class": re.compile("swiper-slide")}) - - destacats.extend(destacats2) - - for c in destacats: - a = c.a["href"] - code = a[-8:-1] - - - html_data = getHtml(Urls.url_datavideos + code + '&profile=pc') - - html_data = html_data.decode("ISO-8859-1") - data = json.loads(html_data) - - if len(data) > 0: - video = self.getVideo(data) - lVideos.append(video) - - except AttributeError as e: - xbmc.log("Exception AtributeError Altres items: " + str(e)) - except KeyError as e: - xbmc.log("Exception KeyError Altres items: " + str(e)) - except Exception as e: - xbmc.log("Exception Item destacat: " + str(e)) - - xbmc.log("listDestaquem len: " + str(len(lVideos))) - - result = [None] * 2 - result[0] = lVideos - return result - - - # mode = noperdis - def listNoPerdis(self): - xbmc.log("--------------listNoPerdis----------") - - lVideos = [] - - link = getHtml(Urls.url_coleccions) - - if link: - - soup = BeautifulSoup(link, "html.parser") - - try: - links = soup.findAll("li", {"class": "sensePunt R-elementLlistat C-llistatVideo"}) - - if not links: - links = soup.findAll("li", {"class": "sensePunt R-elementLlistat C-llistatVideo "}) - - if not links: - links = soup.findAll("li", {"class": "sensePunt R-elementLlistat C-llistatVideo "}) - - for i in links: - a = i.a["href"] - code = a[-8:-1] - - link = getHtml(Urls.url_datavideos + code + '&profile=pc') - - link = link.decode("ISO-8859-1") - data = json.loads(link) - - if len(data) > 0: - video = self.getVideo(data) - lVideos.append(video) - - except AttributeError as e: - xbmc.log("Exception AtributeError NoPerdis: " + str(e)) - except KeyError as e: - xbmc.log("Exception KeyError NoPerdis: " + str(e)) - except Exception as e: - xbmc.log("Exception Item destacat: " + str(e)) - - result = [None] * 2 - result[0] = lVideos - return result - - - # mode = mesvist - def listMesVist(self): - xbmc.log("--------------listMesVist----------") - - lVideos = [] - - link = getHtml(Urls.url_mesvist) - - if link: - - soup = BeautifulSoup(link, "html.parser") - - try: - links = soup.findAll("li", {"class": re.compile("C-llistatVideo")}) - - for i in links: - a = i.a["href"] - code = a[-8:-1] - - link = getHtml(Urls.url_datavideos + code + '&profile=pc') - - link = link.decode("ISO-8859-1") - data = json.loads(link) - - - - if len(data) > 0: - video = self.getVideo(data) - lVideos.append(video) - - except AttributeError as e: - xbmc.log("Exception AtributeError listMesVist: " + str(e)) - except KeyError as e: - xbmc.log("Exception KeyError listMesVist: " + str(e)) - except Exception as e: - xbmc.log("Exception listMesVist: " + str(e)) - - result = [None] * 2 - result[0] = lVideos - return result - - - - # mode = coleccions - def listColeccions(self): - xbmc.log("--------------listColeccions----------") - - lFolderVideos = [] - - link = getHtml(Urls.url_coleccions) - - if link: - - soup = BeautifulSoup(link, "html.parser") - - try: - - colecc = soup.findAll("div", {"class": re.compile("M-destacat")}) - - - for el in colecc: - - url = el.a["href"] - url = Urls.url_base + url - t = el.div.h2.a.string - - titol = t.encode("utf-8") - - - img = el.figure.img["src"] - - - foldVideo = FolderVideo(titol,url, 'getlistvideos', img, img) - lFolderVideos.append(foldVideo) - - except AttributeError as e: - xbmc.log("Exception AtributeError listColeccions: " + str(e)) - except KeyError as e: - xbmc.log("Exception KeyError listColeccions: " + str(e)) - except Exception as e: - xbmc.log("Exception listColeccions: " + str(e)) - - - return lFolderVideos - - - # mode = programes - def dirSections(self): - - return Sections.getList(self.strs) - - # mode = dirAZemisio - def dirAZemisio(self): - - return DirAZemisio.getList() - - #mode = dirAZtots - def dirAZtots(self): - - return DirAZtots.getList() - - # mode = sections - def programsSections(self, url): - xbmc.log("-------------------------programsSections----------------------") - lFolderVideos = [] - - link = getHtml(Urls.url_programes_emisio + url) - - if link: - soup = BeautifulSoup(link) - - try: - # Grups programes de cada lletra - links = soup.findAll("ul", {"class": "R-abcProgrames"}) - - for i in links: - ls = i.findAll("li") - - for li in ls: - url = li.a["href"] - t = str(li.a.string) - titol = re.sub('^[\n\r\s]+', '', t) - - # test url - urlProg = Urls.url_base + url - if urlProg == Urls.urlApm or urlProg == Urls.urlZonaZaping: - url_final = urlProg + 'clips/' - - elif 'super3' in url: - if 'https:' not in url: - url_final = 'https:' + url - else: - url_final = url - - - else: - match = re.compile('(http://www.ccma.cat/tv3/alacarta/.+?/fitxa-programa/)(\d+/)').findall( - urlProg) - if len(match) != 0: - url1 = match[0][0] - urlcode = match[0][1] - - url_final = url1 + 'capitols/' + urlcode - else: - url_final = urlProg + 'capitols/' - - - foldVideo = FolderVideo(titol, url_final, 'getlistvideos', "", "") - lFolderVideos.append(foldVideo) - - except AttributeError as e: - xbmc.log("Exception AtributeError listSections: " + str(e)) - except KeyError as e: - xbmc.log("Exception KeyError listSections: " + str(e)) - except Exception as e: - xbmc.log("Exception listSections: " + str(e)) - - return lFolderVideos - - - # mode = directe - def listDirecte(self): - xbmc.log("-----------------listDirecte--------------------") - lVideos = [] - - data = getDataVideo(Urls.url_arafem) - - if data: - c = data.get('canal', None) - - if c: - - arafemtv3 = '' - arafem33 = '' - arafemesp3 = '' - arafem324 = '' - arafemtv3_sinop = '' - arafem33_sinop = '' - arafemesp3_sinop = '' - arafem324_sinop = '' - - i = 0 - while i < 5: - nameChannel = c[i].get('ara_fem', {}).get('codi_canal', None) - - if nameChannel == 'tv3': - arafemtv3 = c[i].get('ara_fem', {}).get('titol_programa', None) - arafemtv3_sinop = c[i].get('ara_fem', {}).get('sinopsi', None) - if nameChannel == 'cs3' or nameChannel == '33d': - arafem33 = c[i].get('ara_fem', {}).get('titol_programa', None) - arafem33_sinop = c[i].get('ara_fem', {}).get('sinopsi', None) - if nameChannel == 'esport3': - arafemesp3 = c[i].get('ara_fem', {}).get('titol_programa', None) - arafemesp3_sinop = c[i].get('ara_fem', {}).get('sinopsi', None) - if nameChannel == '324': - arafem324 = c[i].get('ara_fem', {}).get('titol_programa', None) - arafem324_sinop = c[i].get('ara_fem', {}).get('sinopsi', None) - - i = i + 1 - - infolabelstv3 = {} - infolabels324 = {} - infolabels33 = {} - infolabelsesp3 = {} - - if arafemtv3: - infolabelstv3['title'] = arafemtv3 - infotv3 = '[B]' + arafemtv3 + '[/B]' + '[CR]' - if arafemtv3_sinop: - if type(arafemtv3) is int or type(arafemtv3) is float: - arafemtv3 = str(arafemtv3) - infotv3 = infotv3 + arafemtv3_sinop - - infolabelstv3['plot'] = infotv3 - - if arafem33: - infolabels33['title'] = arafem33 - info33 = '[B]' + arafem33 + '[/B]' + '[CR]' - if arafem33_sinop: - if type(arafem33) is int or type(arafem33) is float: - arafem33 = str(arafem33) - info33 = info33 + arafem33_sinop - - infolabels33['plot'] = info33 - - if arafemesp3: - infolabelsesp3['title'] = arafemesp3 - infoesp3 = '[B]' + arafemesp3 + '[/B]' + '[CR]' - if arafemesp3_sinop: - if type(arafemesp3) is int or type(arafemesp3) is float: - arafemesp3 = str(arafemesp3) - infoesp3 = infoesp3 + arafemesp3_sinop - - infolabelsesp3['plot'] = infoesp3 - - if arafem324: - infolabels324['title'] = arafem324 - info324 = '[B]' + arafem324 + '[/B]' + '[CR]' - if arafem324_sinop: - if type(arafem324) is int or type(arafem324) is float: - arafem324 = str(arafem324) - info324 = info324 + arafem324_sinop - - infolabels324['plot'] = info324 - - tv3Directe = Video(self.strs.get('tv3'), self.images.thumb_tv3, self.images.thumb_tv3, infolabelstv3, Urls.url_directe_tv3, "") - c324Directe = Video(self.strs.get('canal324'), self.images.thumb_tv3, self.images.thumb_tv3, infolabels324, Urls.url_directe_324, "") - c33s3Directe = Video(self.strs.get('c33super3'), self.images.thumb_tv3, self.images.thumb_tv3, infolabels33, Urls.url_directe_c33s3, "") - sps3Directe = Video(self.strs.get('esport3'), self.images.thumb_tv3, self.images.thumb_tv3, infolabelsesp3, Urls.url_directe_esport3, "") - - tv3DirecteInt = Video(self.strs.get('tv3_int'), self.images.thumb_tv3, self.images.thumb_tv3, infolabelstv3, Urls.url_directe_tv3_int, "") - c324DirecteInt = Video(self.strs.get('canal324_int'), self.images.thumb_tv3, self.images.thumb_tv3, infolabels324, Urls.url_directe_324_int, "") - c33s3DirecteInt = Video(self.strs.get('c33super3_int'), self.images.thumb_tv3, self.images.thumb_tv3, infolabels33, Urls.url_directe_c33s3_int, "") - sps3DirecteInt = Video(self.strs.get('esport3_int'), self.images.thumb_tv3, self.images.thumb_tv3, infolabelsesp3, Urls.url_directe_esport3_int, "") - - lVideos = [tv3Directe, c33s3Directe, c324Directe, sps3Directe, tv3DirecteInt, c33s3DirecteInt, c324DirecteInt, sps3DirecteInt] - - result = [None] * 2 - result[0] = lVideos - return result - - - # mode = progAZ - def programesAZ(self, paramUrl, letters): - xbmc.log("--------------------programesAZ------------------") - letters = urllib.parse.unquote(letters) - lFolderVideos = [] - url = "" - - if paramUrl == "emisio": - url = Urls.url_programes_emisio - else: - url = Urls.url_programes_tots - - html = getHtml(url) - - - if html: - - soup = BeautifulSoup(html.decode('utf-8', 'ignore'), "html.parser") - - elements = soup.findAll("ul", {"class": "R-abcProgrames"}) - - li = None - - - if len(elements) > 0: - - if letters == "#A-C": - - li = elements[0:4] - - elif letters == "D-E": - - li = elements[4:6] - - elif letters == "F-I": - - li = elements[6:10] - - elif letters == "J-L": - - li = elements[10:13] - - elif letters == "M-P": - - li = elements[13:17] - - elif letters == "Q-S": - - li = elements[17:20] - - elif letters == "T-V": - - li = elements[20:23] - - elif letters == "X-Z": - - li = elements[23:] - - if li != None and len(li) > 0: - - for l in li: - - links = l.findAll("li") - - if len(links) > 0: - - for i in links: - #xbmc.log("progsAZ - li: " + str(i).encode('utf-8')) - - url = i.a["href"] - titol = i.a.string.strip().encode("utf-8") - - # test url - urlProg = Urls.url_base + url - if urlProg == Urls.urlApm or urlProg == Urls.urlZonaZaping: - url_final = urlProg + 'clips/' - - elif 'super3' in url: - if 'https:' not in url: - url_final = 'https:' + url - else: - url_final = url - - else: - match = re.compile( - '(http://www.ccma.cat/tv3/alacarta/.+?/fitxa-programa/)(\d+/)').findall(urlProg) - if len(match) != 0: - url1 = match[0][0] - urlcode = match[0][1] - - url_final = url1 + 'capitols/' + urlcode - else: - url_final = urlProg + 'capitols/' - - - folderVideo = FolderVideo(titol, url_final, 'getlistvideos', "", "") - lFolderVideos.append(folderVideo) - #xbmc.log("progsAZ - Titol: " + titol) - #xbmc.log("progsAZ - url: " + url_final) - - - return lFolderVideos - - # mode = getlistvideos - def getListVideos(self, url, cercar): - xbmc.log("---------------getListVideos------------------------------") - result = [None] * 2 - lVideos = [] - - xbmc.log('getListVideos--Url listvideos: ' + url) - - link = getHtml(url) - - if link: - - soup = BeautifulSoup(link.decode('utf-8', 'ignore'), "html.parser") - - links = None - try: - links = soup.findAll("div", {"class": "F-itemContenidorIntern C-destacatVideo"}) - - if not links: - links = soup.findAll("li", {"class": "F-llistat-item"}) - - # Coleccions - if not links: - links = soup.findAll("div", {"class": re.compile("M-destacat")}) - - # Zona Zapping - if not links: - links = soup.findAll("article", {"class": "M-destacat C-destacatVideo T-alacartaTema C-3linies "}) - - # Super 3 - if not links: - - links = soup.findAll("div", - {"class": "M-destacat super3 T-video ombres-laterals"}) - links2 = soup.findAll("div", - {"class": "M-destacat super3 noGapAfter T-video ombres-laterals"}) - links = links + links2 - - # Super 3 - if not links: - links = soup.findAll("article", - {"class": "M-destacat super3 noGapAfter T-video ombres-laterals"}) - - - except AttributeError as e: - xbmc.log("getListVideos--getLinks--Exception AtributeError listVideos: " + str(e)) - except KeyError as e: - xbmc.log("getListVideos--getLinks--Exception KeyError listVideos: " + str(e)) - except Exception as e: - xbmc.log("getListVideos--getLinks--Exception listVideos: " + str(e)) - - if links: - - for l in links: - - try: - - urlvideo = l.a["href"] - - code = urlvideo.split('/')[-1] - - if len(code) == 0: - code = urlvideo.split('/')[-2] - - - html_data = getHtml(Urls.url_datavideos + code + '&profile=pc') - - html_data = html_data.decode("ISO-8859-1") - data = json.loads(html_data) - - if len(data) > 0: - video = self.getVideo(data) - lVideos.append(video) - - - - - except AttributeError as e: - xbmc.log("getListVideos--bucle addVideo--Exception AtributeError: " + str(e)) - - except KeyError as e: - xbmc.log("getListVideos--bucle addVideo--Exception KeyError: " + str(e)) - - except Exception as e: - xbmc.log("getListVideos--bucle addVideo--Exception: " + str(e)) - - result[0] = lVideos - - ############################################################################### - - # Pagination - ht = rb'

P\xc3\xa0gina (\d+) de (\d+)

' - - match = re.compile(ht).findall(link) - if len(match) != 0: - actualPage = int(match[0][0]) - totalPages = int(match[0][1]) - - if actualPage < totalPages: - ntPage = str(actualPage + 1) - nextPage = '&pagina=' + ntPage - if cercar: - if actualPage == 1: - url_next = url + nextPage - else: - url_next = re.sub('&pagina=[\d]+', nextPage, url) - else: - url_next = url + '?text=&profile=&items_pagina=15' + nextPage - foldNext = FolderVideo(self.strs.get('seguent'), url_next, "getlistvideos", "","") - foldNext.hasNextPage = True - result[1] = foldNext - - return result - - - def getVideo(self, data): - linkvideo = None - media = data.get('media', {}) - - if type(media) is list and len(media) > 0: - media_dict = media[0] - linkvideo = media_dict.get('url', None) - else: - linkvideo = media.get('url', None) - - if linkvideo != None: - if type(linkvideo) is list and len(linkvideo) > 0: - linkvideo_item = linkvideo[0] - urlVideo = linkvideo_item.get('file', None) - - titol = data.get('informacio', {}).get('titol', None) - image = data.get('imatges', {}).get('url', None) - descripcio = data.get('informacio', {}).get('descripcio', None) - programa = data.get('informacio', {}).get('programa', None) - capitol = data.get('informacio', {}).get('capitol', None) - tematica = data.get('informacio', {}).get('tematica', {}).get('text', None) - data_emisio = data.get('informacio', {}).get('data_emissio', {}).get('text', None) - milisec = data.get('informacio', {}).get('durada', {}).get('milisegons', None) - durada = "" - - if milisec != None: - durada = milisec // 1000 - - - if descripcio == None: - descripcio = '' - else: - descripcio = descripcio.replace('
', '') - - header = "" - if programa != None: - if type(programa) is int or type(programa) is float: - programa = str(programa) - header = '[B]' + programa + '[/B]' + '[CR]' - - infolabels = {} - if data_emisio != None: - dt = data_emisio[0:10] - year = data_emisio[6:10] - infolabels['aired'] = dt - infolabels['year'] = year - header = header + dt + '[CR]' - - descripcio = header + descripcio - - if titol != None: - infolabels['title'] = titol - - - if capitol != None: - infolabels['episode'] = capitol - - - if descripcio != None: - infolabels['plot'] = descripcio - - if tematica != None: - infolabels['genre'] = tematica - - video = Video(titol, image, image, infolabels, urlVideo, durada ) - - return video - - else: - return None - - #mode = cercar - def search(self): - - keyboard = xbmc.Keyboard('', self.strs.get('cercar')) - keyboard.doModal() - if keyboard.isConfirmed() and keyboard.getText(): - search_string = keyboard.getText().replace(" ", "+") - url = "http://www.ccma.cat/tv3/alacarta/cercador/?items_pagina=15&profile=videos&text=" + search_string - - lVideos = self.getListVideos(url, True) - - return lVideos - diff --git a/plugin.video.tv3.cat/resources/lib/ui/UI.py b/plugin.video.tv3.cat/resources/lib/ui/UI.py deleted file mode 100644 index f5782d77a6..0000000000 --- a/plugin.video.tv3.cat/resources/lib/ui/UI.py +++ /dev/null @@ -1,247 +0,0 @@ -from builtins import str -from builtins import object -from resources.lib.utils.Utils import buildUrl -from resources.lib.tv3cat.TV3cat import TV3cat -import xbmcaddon -import xbmcplugin -import xbmcgui -import xbmc -import xbmcvfs -import urllib.parse - - -class UI(object): - - def __init__(self, base_url, addon_handle, args): - addon = xbmcaddon.Addon() - addon_path = xbmcvfs.translatePath(addon.getAddonInfo('path')) - self.tv3 = TV3cat(addon_path, addon) - self.base_url = base_url - self.addon_handle = addon_handle - self.args = args - self.mode = args.get('mode', None) - self.url = args.get('url', ['']) - self.name = args.get('name', None) - xbmc.log("plugin.video.tv3.cat classe UI - init() ") - - - def run(self, mode, url): - xbmc.log("plugin.video.tv3.cat classe UI - run() mode = " + str(mode)) - - - if mode == None: - xbmc.log("plugin.video.tv3.cat classe UI - mode = None") - lFolder = self.tv3.listHome() - - if len(lFolder) > 0: - self.listFolder(lFolder) - else: - xbmc.log("UI.run() Home - No existeixen elements") - - elif mode[0] == 'destaquem': - xbmc.log("plugin.video.tv3.cat classe UI - mode = destaquem") - lVideos = self.tv3.listDestaquem() - - if len(lVideos) > 0: - self.listVideos(lVideos) - else: - xbmc.log("UI.run() destaquem - No existeixen videos") - - - elif mode[0] == 'noperdis': - - lVideos = self.tv3.listNoPerdis() - - if len(lVideos) > 0: - self.listVideos(lVideos) - else: - xbmc.log("UI.run() noperdis - No existeixen videos") - - elif mode[0] == 'mesvist': - - lVideos = self.tv3.listMesVist() - - if len(lVideos) > 0: - self.listVideos(lVideos) - else: - xbmc.log("UI.run() mesvist - No existeixen videos") - - elif mode[0] == 'programes': - - lFolder = self.tv3.dirSections() - - if len(lFolder) > 0: - self.listFolder(lFolder) - else: - xbmc.log("UI.run() programes - No existeixen elements") - - elif mode[0] == 'sections': - - lFolder = self.tv3.programsSections(url[0]) - - if len(lFolder) > 0: - self.listFolder(lFolder) - else: - xbmc.log("UI.run() sections - No existeixen elements") - - elif mode[0] == 'dirAZemisio': - - lFolder = self.tv3.dirAZemisio() - - if len(lFolder) > 0: - self.listFolder(lFolder) - else: - xbmc.log("UI.run() dirAZemisio - No existeixen elements") - - elif mode[0] == 'dirAZtots': - - lFolder = self.tv3.dirAZtots() - - if len(lFolder) > 0: - self.listFolder(lFolder) - else: - xbmc.log("UI.run() dirAZtots - No existeixen elements") - - elif mode[0] == 'progAZ': - letters = self.name[0] - lFolder = self.tv3.programesAZ(url[0], letters) - - if len(lFolder) > 0: - self.listFolder(lFolder) - else: - xbmc.log("UI.run() progAZ - No existeixen elements") - - elif mode[0] == 'directe': - - lVideos = self.tv3.listDirecte() - self.listVideos(lVideos) - - elif mode[0] == 'cercar': - - lVideos = self.tv3.search() - - if len(lVideos) > 0: - self.listVideos(lVideos) - else: - xbmc.log("UI.run() cercar - No s'ha trobat cap video") - - - elif mode[0] == 'getlistvideos': - - lVideos = self.tv3.getListVideos(url[0], None) - self.listVideos(lVideos) - - elif mode[0] == 'coleccions': - - lFolder = self.tv3.listColeccions() - self.listFolder(lFolder) - - elif mode[0] == 'playVideo': - - self.playVideo(url[0]) - - def listFolder(self, lFolderVideos): - xbmc.log("plugin.video.tv3.cat classe UI - listFolder") - for folder in lFolderVideos: - - mode = folder.mode - name = folder.name - nameQuoted = urllib.parse.quote(name) - url = folder.url - iconImage = folder.iconImage - thumbImage = folder.thumbnailImage - - urlPlugin = buildUrl({'mode': mode, 'name': nameQuoted, 'url': url}, self.base_url) - liz = xbmcgui.ListItem(name) - liz.setInfo(type="Video", infoLabels={"title": name}) - liz.setArt({'thumb': thumbImage, 'icon' : iconImage}) - - xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=urlPlugin, listitem=liz, isFolder=True) - xbmcplugin.endOfDirectory(self.addon_handle) - - def listVideos(self, lVideos): - - xbmc.log("--------List videos ----------") - last = lVideos[1] - listVideos = lVideos[0] - if not listVideos: - xbmc.log("UI - listVideos - Numero videos: 0") - else: - xbmc.log("UI - listVideos - Numero videos: " + str(len(listVideos))) - - - - for video in listVideos: - if video: - urlVideo = video.url - xbmc.log("UI - listVideos - urlVideo: " + urlVideo) - iconImage = video.iconImage - thumbImage = video.thumbnailImage - durada = video.durada - titol = video.title - - urlPlugin = buildUrl({'mode':'playVideo','name':"",'url':urlVideo}, self.base_url) - - liz = xbmcgui.ListItem(titol) - - infolabels = video.information - - liz.setInfo('video', infolabels) - liz.setArt({'thumb': thumbImage, 'icon': "DefaultVideo.png"}) - liz.addStreamInfo('video', {'duration': durada}) - liz.setProperty('isPlayable', 'true') - xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=urlPlugin, listitem=liz) - - if last: - mode = last.mode - name = last.name - url = last.url - #xbmc.log("UI - listVideos - urlNext: " + url) - iconImage = last.iconImage - thumbImage = last.thumbnailImage - - urlPlugin = buildUrl({'mode': mode, 'name': '', 'url': url}, self.base_url) - liz = xbmcgui.ListItem(name) - liz.setInfo(type="Video", infoLabels={"title": name}) - liz.setArt({'thumb': thumbImage, 'icon': iconImage}) - - xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=urlPlugin, listitem=liz, isFolder=True) - - xbmcplugin.endOfDirectory(self.addon_handle) - - def playVideo(self,url): - code = url[-8:-1] - xbmc.log("UI - playVideo") - - - # html_data = getHtml(url_datavideos + code + '&profile=pc') - # - # if html_data: - # - # html_data = html_data.decode("ISO-8859-1") - # data = json.loads(html_data) - # - # urlvideo = None - # - # if len(data) > 0: - # - # media = data.get('media', {}) - # - # if type(media) is list and len(media) > 0: - # media_dict = media[0] - # urlvideo = media_dict.get('url', None) - # else: - # urlvideo = media.get('url', None) - # - # if urlvideo: - # if type(urlvideo) is list and len(urlvideo) > 0: - # urlvideo_item = urlvideo[0] - # video = urlvideo_item.get('file', None) - # - # else: - # video = url - # - # xbmc.log("Play video - url: " + video) - - item = xbmcgui.ListItem(path=url) - xbmcplugin.setResolvedUrl(self.addon_handle, True, item) \ No newline at end of file