From a08ff9d63b412487ea87a1e28b83e77fb9e669dc Mon Sep 17 00:00:00 2001 From: LaQuay Date: Fri, 2 Aug 2019 20:47:45 +0200 Subject: [PATCH] test commit --- .gitignore | 3 +- script/__init__.py | 0 script/ambit.py | 47 -------- script/channel.py | 102 ----------------- script/country.py | 43 ------- script/public/analytics.js | 22 ---- script/public/index.html | 133 ---------------------- script/public/index.js | 223 ------------------------------------- script/public/styles.css | 10 -- script/radio_script.py | 190 ------------------------------- script/requirements.txt | 1 - script/tv_script.py | 204 --------------------------------- script/utils.py | 106 ------------------ 13 files changed, 2 insertions(+), 1082 deletions(-) delete mode 100644 script/__init__.py delete mode 100644 script/ambit.py delete mode 100644 script/channel.py delete mode 100644 script/country.py delete mode 100644 script/public/analytics.js delete mode 100644 script/public/index.html delete mode 100644 script/public/index.js delete mode 100644 script/public/styles.css delete mode 100644 script/radio_script.py delete mode 100644 script/requirements.txt delete mode 100644 script/tv_script.py delete mode 100644 script/utils.py diff --git a/.gitignore b/.gitignore index c2bc5577..69f2baf0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ venv/ .idea/ __pycache__/ -script/public/output/ \ No newline at end of file +script/public/output/ +script \ No newline at end of file diff --git a/script/__init__.py b/script/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/script/ambit.py b/script/ambit.py deleted file mode 100644 index 8756d88d..00000000 --- a/script/ambit.py +++ /dev/null @@ -1,47 +0,0 @@ -class Ambito: - def __init__(self, name, channels): - self.name = name - self.channels = channels - - def add_channels(self, channels_to_add): - if self.channels: - self.channels += channels_to_add - - def __channels_to_json__(self): - channel_list = [] - for channel in self.channels: - channel_list.append(channel.to_json()) - return channel_list - - def to_json(self): - return { - "name": self.name, - "channels": self.__channels_to_json__() - } - - def __channels_to_m3u8__(self): - channels_list = "" - for channel in self.channels: - for option in channel.get_options(): - if option.is_m3u8_valid(): - channels_list += channel.to_m3u8(self.name, option) - return channels_list - - def to_m3u8(self): - return self.__channels_to_m3u8__() - - def __channels_to_enigma2__(self): - channels_list = "" - counter = 3 - for channel in self.channels: - for option in channel.get_options(): - if option.is_m3u8_valid(): - channels_list += channel.to_enigma2(option, counter) - counter += 2 - return channels_list - - def to_enigma2(self): - return self.__channels_to_enigma2__() - - def __str__(self): - return self.name diff --git a/script/channel.py b/script/channel.py deleted file mode 100644 index e53e0f40..00000000 --- a/script/channel.py +++ /dev/null @@ -1,102 +0,0 @@ -# TODO Create TVChannel and RadioChannel -class Channel: - def __init__(self, name, web, resolution, logo, epg_id, extra_info): - self.name = name - self.web = web - self.resolution = resolution - self.logo = logo - self.epg_id = epg_id - self.options = [] - self.extra_info = extra_info - - def add_option(self, format, url): - self.options.append(self.Web(format, url)) - - def get_name(self): - return self.name - - def get_resolution(self): - return self.get_resolution - - def get_logo(self): - return self.logo - - def get_epg(self): - return self.epg_id - - def get_options(self): - return self.options - - def get_extra_info(self): - return self.extra_info - - def __str__(self): - options_string = "" - for option in self.options: - options_string += f"[Format: {option.get_format()}, URL: {option.get_url()}]" - return self.name + " " + options_string - - def __options_to_json__(self): - options_list = [] - for option in self.options: - options_list.append(option.to_json()) - return options_list - - def to_json(self): - return { - "name": self.name, - "web": self.web, - "logo": self.logo, - "resolution": self.resolution, - "epg_id": self.epg_id, - "options": self.__options_to_json__(), - "extra_info": self.extra_info - } - - def to_m3u8(self, ambit_name, option): - info = '#EXTINF:-1' - if self.epg_id != "": - info += f' tvg-id="{self.epg_id}"' - if self.logo != "": - info += f' tvg-logo="{self.logo}"' - if ambit_name != "": - info += f' group-title="{ambit_name}"' - - info += f',{self.name}' - info += f'\n{option.get_url()}\n' - - return info - - def to_enigma2(self, option, counter): - info = f'#SERVICE 4097:0:1:{counter}:0:0:0:0:0:0' - info += f':{option.get_url(double_dot=False)}' - info += f':{self.name}\n' - info += f'#DESCRIPTION {self.name}\n' - - return info - - class Web: - def __init__(self, format, url): - self.format = format - self.url = url - - def is_m3u8_valid(self): - return self.format == "m3u8" - - def get_format(self): - return self.format - - def get_url(self, double_dot=True): - if double_dot: - return self.url - else: - return self.url.replace(":", "%3a") - - def __str__(self): - return self.format + ", " + self.url - - def to_json(self): - return { - "format": self.format, - "url": self.url - } diff --git a/script/country.py b/script/country.py deleted file mode 100644 index 4f127927..00000000 --- a/script/country.py +++ /dev/null @@ -1,43 +0,0 @@ -class Country: - def __init__(self, name): - self.name = name - self.ambits = [] - - def add_ambit(self, ambit): - self.ambits.append(ambit) - - def get_ambit(self, ambit_to_get): - for ambit in self.ambits: - if ambit.name == ambit_to_get: - return ambit - return None - - def __ambits_to_json__(self): - ambits_list = [] - for ambit in self.ambits: - ambits_list.append(ambit.to_json()) - return ambits_list - - def to_json(self): - return { - "name": self.name, - "ambits": self.__ambits_to_json__() - } - - def __ambits_to_m3u8__(self): - ambits_list = "" - for ambit in self.ambits: - ambits_list += ambit.to_m3u8() - return ambits_list - - def to_m3u8(self): - return self.__ambits_to_m3u8__() - - def __ambits_to_enigma2__(self): - ambits_list = "" - for ambit in self.ambits: - ambits_list += ambit.to_enigma2() - return ambits_list - - def to_enigma2(self): - return self.__ambits_to_enigma2__() diff --git a/script/public/analytics.js b/script/public/analytics.js deleted file mode 100644 index 083dfa26..00000000 --- a/script/public/analytics.js +++ /dev/null @@ -1,22 +0,0 @@ -function loadGoogleAnalytics(){ - window.dataLayer = window.dataLayer || []; - function gtag() { - dataLayer.push(arguments); - } - gtag('js', new Date()); - gtag('config', 'UA-27327609-3'); -} - -function loadGoogleTagManager() { - (function(i,s,o,g,r,a,m){ - i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - }) - (window,document,'script','https://www.google-analytics.com/analytics.js','ga'); - ga('create', 'UA-27327609-3', 'auto'); - ga('send', 'pageview'); -} - -loadGoogleAnalytics(); -loadGoogleTagManager(); \ No newline at end of file diff --git a/script/public/index.html b/script/public/index.html deleted file mode 100644 index f2bff804..00000000 --- a/script/public/index.html +++ /dev/null @@ -1,133 +0,0 @@ - - - - TDT Channels - Marc Vila - - - - - - - - - - - - - - - -
-

TDTChannels

-
- Repositorio TDT Channels - Marc Vila - GitHub - LinkedIn -
-
- -
-
-
-
-

- Reproductor de Televisión -

- -
- -
- -
-
-
-
-

Información de la reproducción

- Formatos soportados -
- m3u8 -

- Resoluciones disponibles -
- -

-
-
-
-
-

- Reproductor de Radio -

-
- -
- -
-
- -
-

Información de la reproducción

- Formatos soportados -
- aac, mp3, nsv, audio/mpeg, pls(Beta) - - -
-
-
-
-
- - - - - \ No newline at end of file diff --git a/script/public/index.js b/script/public/index.js deleted file mode 100644 index a31f7371..00000000 --- a/script/public/index.js +++ /dev/null @@ -1,223 +0,0 @@ -// Se espera en la URL este tipo de llamada .html?type={audio,video}&channel={url_a_reproducir} -function loadItem(from) { - var value; - if (from == "audio") { - value = document.getElementById("input-reproduccion-audio").value; - reproduceAudio(value); - } else if (from == "video") { - value = document.getElementById("input-reproduccion-video").value; - reproduceVideo(value); - } -} - -function reproduceVideo(channelToReproduce) { - console.log("Reproducing video: " + channelToReproduce); - if (channelToReproduce.includes("m3u8")) { - var divInfo = document.getElementById("video-player").childElementCount; - if (divInfo == 0) { - player = new Clappr.Player({ - source: channelToReproduce, - parentId: '#video-player', - height: '500px', - width: '100%', - autoPlay: true, - }); - } else { - // Assume player instance is already created - player.configure({ - source: channelToReproduce, - }); - } - clearResolutions(); - getResolution(channelToReproduce, updateResolution); - } - - ga('send', { - hitType: 'event', - eventCategory: 'Video', - eventAction: 'play', - eventLabel: channelToReproduce - }); -} - -function reproduceAudio(channelToReproduce) { - if (channelToReproduce.includes("pls")) { - getURLsFromPLS(channelToReproduce, reproducePLSFromUrl); - } else { - reproduceAudioFromUrl(channelToReproduce); - } -} - -function reproduceAudioFromUrl(channelToReproduce) { - console.log("Reproducing audio: " + channelToReproduce); - var audioSource = document.getElementById('audio-controller'); - var audioPlayer = document.getElementById('audio-player'); - - audioPlayer.src = channelToReproduce; - audioSource.load(); - audioSource.pause(); - - var playPromise = audioSource.play(); - if (playPromise !== undefined) { - playPromise.then(function() { - // Automatic playback started! - }).catch(function(error) { - // Automatic playback failed. - // Show a UI element to let the user manually start playback. - }); - } - - ga('send', { - hitType: 'event', - eventCategory: 'Audio', - eventAction: 'play', - eventLabel: channelToReproduce - }); -} - -function reproducePLSFromUrl(data) { - reproduceAudioFromUrl(data[0]); - updateExtraAudioInfo("pls_more_url_available", data); -} - -function updateResolution(resolutions) { - console.log("Resoluciones: " + resolutions); - - for (i = 0; i < resolutions.length; i++) { - var resolutionToAdd = resolutions[i]; - if (i < resolutions.length - 1){ - resolutionToAdd += ", "; - } - document.getElementById("video-resolution").innerHTML += resolutionToAdd; - } -} - -function clearResolutions() { - document.getElementById("video-resolution").innerHTML = ""; -} - -function updateExtraAudioInfo(type, data) { - console.log("Extra info type: " + type); - console.log("Extra info data: " + data); - - var textToAdd = ""; - if (type == "pls_more_url_available") { - for (i = 0; i < data.length; i++) { - textToAdd += data[i] + "
"; - } - } - - document.getElementById("extra-audio-info").innerHTML = textToAdd; - document.getElementById("extra-audio-info-div").style.display = "block"; -} - -function getURLsFromPLS(sUrl, fn_callback) { - $.get(sUrl, function(data) { - $response = data.split("\n"); - - $urls=[]; - $.each($response, function( index, value ) { - $line_separated_value = value.split("="); - if ($line_separated_value.length > 1 && $line_separated_value[1].indexOf("http") != -1) { - $urls.push($line_separated_value[1]); - } - }); - fn_callback($urls) - }); -}; - -function getResolution(from, fn_callback) { - $.get(from, function(data) { - $response = data.split("\n"); - - $resolutions=[]; - $.each($response, function( index, value ) { - $line_separated_value = value.split(","); - for (i = 0; i < $line_separated_value.length; i++) { - if ($line_separated_value[i].indexOf("RESOLUTION=") != -1) { - $resolutions.push($line_separated_value[i].split('=')[1]); - } - } - }); - - fn_callback($resolutions); - }); -} - -function getUrlParameter(sParam) { - var sPageURL = decodeURIComponent(window.location.search.substring(1)), - sURLVariables = sPageURL.split('&'), - sParameterName, - i; - - for (i = 0; i < sURLVariables.length; i++) { - sParameterName = sURLVariables[i].split('='); - - if (sParameterName[0] === sParam) { - return sParameterName[1] === undefined ? true : sParameterName[1]; - } - } -}; - -function filterChannelsList() { - var input, filter, div, elements, txtValue; - - input = document.getElementById("searchInput"); - filter = input.value.toUpperCase(); - div = document.getElementById("channel-list"); - elements = div.getElementsByTagName("a"); - - for (i = 0; i < elements.length; i++) { - txtValue = elements[i].textContent || elements[i].innerText; - if (txtValue.toUpperCase().indexOf(filter) > -1) { - elements[i].style.display = ""; - } else { - elements[i].style.display = "none"; - } - } -} - -function reproduceChannel(channel_options) { - document.getElementById("option-buttons").innerHTML = "" - if (channel_options.length > 0) { - reproduceVideo(channel_options[0]['url']) - - if (channel_options.length > 1) { - for (i = 0; i < channel_options.length; ++i) { - var url = channel_options[i]['url']; - document.getElementById("option-buttons").innerHTML += - "Opción " + (i+1) + ""; - } - } - } else { - reproduceVideo("no_video_found.m3u8") - } -} - -function onChannelClick(channel) { - channel = JSON.parse(channel); - reproduceChannel(channel['options']) - - if (document.getElementById("container").offsetWidth < 720) { - document.getElementById("video").scrollIntoView({behavior: "smooth", block: "start", inline: "nearest"}); - } -} - -function loadChannelsInList() { - fetch('http://91.121.64.179/tdt_project/output/channels.json') - .then(function(response) { - return response.json(); - }) - .then(function(myJson) { - nacionales = myJson[1]; - - var items = []; - $.each(nacionales["ambits"], function( ambit, ambit_val ) { - $.each(ambit_val["channels"], function( key, val ) { - items.push("" + val["name"] + "") - }); - }); - - $(items.join( "" )).appendTo(".channels-list"); - }); -} \ No newline at end of file diff --git a/script/public/styles.css b/script/public/styles.css deleted file mode 100644 index b40fe158..00000000 --- a/script/public/styles.css +++ /dev/null @@ -1,10 +0,0 @@ -.container[data-container] { - max-width: 100% !important; -} - -.list-group{ - max-height: 70vh; - overflow: scroll; - overflow-x: hidden; - -webkit-overflow-scrolling: touch; -} \ No newline at end of file diff --git a/script/radio_script.py b/script/radio_script.py deleted file mode 100644 index 7759a4e9..00000000 --- a/script/radio_script.py +++ /dev/null @@ -1,190 +0,0 @@ -# coding=utf-8 -import json - -import requests - -from ambit import Ambito -from country import Country -from utils import stringbetween, get_radio_channels_from_part, get_license_info - -page = requests.get('https://raw.githubusercontent.com/LaQuay/TDTChannels/master/RADIO.md', - headers={'Cache-Control': 'no-cache'}) -content = str(page.text) - -print("Updating RADIO files") - -spain = Country("Spain") -andorra = Country("Andorra") -international = Country("International") - -content_nacional = stringbetween(content, "## Nacionales", "## Locales") -content_local = stringbetween(content, "## Locales", "## Internacionales") - -canales_nacionales = stringbetween(content_nacional, "", "## Deportivos") -spain.add_ambit(Ambito("Generalistas", get_radio_channels_from_part(canales_nacionales))) - -canales_deportivos = stringbetween(content_nacional, "## Deportivos", "## Autonómicos") -spain.add_ambit(Ambito("Deportivos", get_radio_channels_from_part(canales_deportivos))) - -canales_autonomicos_andalucia = stringbetween(content_nacional, "### Andalucía", "### Aragón") -spain.add_ambit(Ambito("Andalucía", get_radio_channels_from_part(canales_autonomicos_andalucia))) - -canales_autonomicos_aragon = stringbetween(content_nacional, "### Aragón", "### Asturias") -spain.add_ambit(Ambito("Aragón", get_radio_channels_from_part(canales_autonomicos_aragon))) - -canales_autonomicos_asturias = stringbetween(content_nacional, "### Asturias", "### Canarias") -spain.add_ambit(Ambito("Asturias", get_radio_channels_from_part(canales_autonomicos_asturias))) - -canales_autonomicos_canarias = stringbetween(content_nacional, "### Canarias", "### Cantabria") -spain.add_ambit(Ambito("Canarias", get_radio_channels_from_part(canales_autonomicos_canarias))) - -canales_autonomicos_cantabria = stringbetween(content_nacional, "### Cantabria", "### Castilla La-Mancha") -spain.add_ambit(Ambito("Cantabria", get_radio_channels_from_part(canales_autonomicos_cantabria))) - -canales_autonomicos_castilla_mancha = stringbetween(content_nacional, "### Castilla La-Mancha", "### Castilla y León") -spain.add_ambit(Ambito("Castilla La-Mancha", get_radio_channels_from_part(canales_autonomicos_castilla_mancha))) - -canales_autonomicos_castilla_leon = stringbetween(content_nacional, "### Castilla y León", "### Cataluña") -spain.add_ambit(Ambito("Castilla y León", get_radio_channels_from_part(canales_autonomicos_castilla_leon))) - -canales_autonomicos_catalunya = stringbetween(content_nacional, "### Cataluña", "### Ceuta") -spain.add_ambit(Ambito("Cataluña", get_radio_channels_from_part(canales_autonomicos_catalunya))) - -canales_autonomicos_ceuta = stringbetween(content_nacional, "### Ceuta", "### Extremadura") -spain.add_ambit(Ambito("Ceuta", get_radio_channels_from_part(canales_autonomicos_ceuta))) - -canales_autonomicos_extremadura = stringbetween(content_nacional, "### Extremadura", "### Galicia") -spain.add_ambit(Ambito("Extremadura", get_radio_channels_from_part(canales_autonomicos_extremadura))) - -canales_autonomicos_galicia = stringbetween(content_nacional, "### Galicia", "### Islas Baleares") -spain.add_ambit(Ambito("Galicia", get_radio_channels_from_part(canales_autonomicos_galicia))) - -canales_autonomicos_islas_baleares = stringbetween(content_nacional, "### Islas Baleares", "### La Rioja") -spain.add_ambit(Ambito("Islas Baleares", get_radio_channels_from_part(canales_autonomicos_islas_baleares))) - -canales_autonomicos_la_rioja = stringbetween(content_nacional, "### La Rioja", "### Madrid") -spain.add_ambit(Ambito("La Rioja", get_radio_channels_from_part(canales_autonomicos_la_rioja))) - -canales_autonomicos_madrid = stringbetween(content_nacional, "### Madrid", "### Melilla") -spain.add_ambit(Ambito("Madrid", get_radio_channels_from_part(canales_autonomicos_madrid))) - -canales_autonomicos_melilla = stringbetween(content_nacional, "### Melilla", "### Murcia") -spain.add_ambit(Ambito("Melilla", get_radio_channels_from_part(canales_autonomicos_melilla))) - -canales_autonomicos_murcia = stringbetween(content_nacional, "### Murcia", "### Navarra") -spain.add_ambit(Ambito("Murcia", get_radio_channels_from_part(canales_autonomicos_murcia))) - -canales_autonomicos_navarra = stringbetween(content_nacional, "### Navarra", "### País Vasco") -spain.add_ambit(Ambito("Navarra", get_radio_channels_from_part(canales_autonomicos_navarra))) - -canales_autonomicos_pais_vasco = stringbetween(content_nacional, "### País Vasco", "### Valencia") -spain.add_ambit(Ambito("País Vasco", get_radio_channels_from_part(canales_autonomicos_pais_vasco))) - -canales_autonomicos_valencia = stringbetween(content_nacional, "### Valencia", "") -spain.add_ambit(Ambito("Valencia", get_radio_channels_from_part(canales_autonomicos_valencia))) - -canales_locales_andalucia = stringbetween(content_local, "### Andalucía", "### Aragón") -spain.get_ambit("Andalucía").add_channels(get_radio_channels_from_part(canales_locales_andalucia)) - -canales_locales_aragon = stringbetween(content_local, "### Aragón", "### Asturias") -spain.get_ambit("Aragón").add_channels(get_radio_channels_from_part(canales_locales_aragon)) - -canales_locales_asturias = stringbetween(content_local, "### Asturias", "### Canarias") -spain.get_ambit("Asturias").add_channels(get_radio_channels_from_part(canales_locales_asturias)) - -canales_locales_canarias = stringbetween(content_local, "### Canarias", "### Cantabria") -spain.get_ambit("Canarias").add_channels(get_radio_channels_from_part(canales_locales_canarias)) - -canales_locales_cantabria = stringbetween(content_local, "### Cantabria", "### Castilla La-Mancha") -spain.get_ambit("Cantabria").add_channels(get_radio_channels_from_part(canales_locales_cantabria)) - -canales_locales_castilla_mancha = stringbetween(content_local, "### Castilla La-Mancha", "### Castilla y León") -spain.get_ambit("Castilla La-Mancha").add_channels(get_radio_channels_from_part(canales_locales_castilla_mancha)) - -canales_locales_castilla_leon = stringbetween(content_local, "### Castilla y León", "### Cataluña") -spain.get_ambit("Castilla y León").add_channels(get_radio_channels_from_part(canales_locales_castilla_leon)) - -canales_locales_catalunya = stringbetween(content_local, "### Cataluña", "### Ceuta") -spain.get_ambit("Cataluña").add_channels(get_radio_channels_from_part(canales_locales_catalunya)) - -canales_locales_ceuta = stringbetween(content_local, "### Ceuta", "### Extremadura") -spain.get_ambit("Ceuta").add_channels(get_radio_channels_from_part(canales_locales_ceuta)) - -canales_locales_extremadura = stringbetween(content_local, "### Extremadura", "### Galicia") -spain.get_ambit("Extremadura").add_channels(get_radio_channels_from_part(canales_locales_extremadura)) - -canales_locales_galicia = stringbetween(content_local, "### Galicia", "### Islas Baleares") -spain.get_ambit("Galicia").add_channels(get_radio_channels_from_part(canales_locales_galicia)) - -canales_locales_islas_baleares = stringbetween(content_local, "### Islas Baleares", "### La Rioja") -spain.get_ambit("Islas Baleares").add_channels(get_radio_channels_from_part(canales_locales_islas_baleares)) - -canales_locales_la_rioja = stringbetween(content_local, "### La Rioja", "### Madrid") -spain.get_ambit("La Rioja").add_channels(get_radio_channels_from_part(canales_locales_la_rioja)) - -canales_locales_madrid = stringbetween(content_local, "### Madrid", "### Melilla") -spain.get_ambit("Madrid").add_channels(get_radio_channels_from_part(canales_locales_madrid)) - -canales_locales_melilla = stringbetween(content_local, "### Melilla", "### Murcia") -spain.get_ambit("Melilla").add_channels(get_radio_channels_from_part(canales_locales_melilla)) - -canales_locales_murcia = stringbetween(content_local, "### Murcia", "### Navarra") -spain.get_ambit("Murcia").add_channels(get_radio_channels_from_part(canales_locales_murcia)) - -canales_locales_navarra = stringbetween(content_local, "### Navarra", "### País Vasco") -spain.get_ambit("Navarra").add_channels(get_radio_channels_from_part(canales_locales_navarra)) - -canales_locales_pais_vasco = stringbetween(content_local, "### País Vasco", "### Valencia") -spain.get_ambit("País Vasco").add_channels(get_radio_channels_from_part(canales_locales_pais_vasco)) - -canales_locales_valencia = stringbetween(content_local, "### Valencia", "") -spain.get_ambit("Valencia").add_channels(get_radio_channels_from_part(canales_locales_valencia)) - -canales_internacionales = stringbetween(content, "## Internacionales", "## Andorra") -international.add_ambit(Ambito("Internacional", get_radio_channels_from_part(canales_internacionales))) - -canales_andorra = stringbetween(content, "## Andorra", "") -andorra.add_ambit(Ambito("Andorra", get_radio_channels_from_part(canales_andorra))) - -# Save data to JSON file -json_file = open('./public/output/radio_channels.json', "w+") -json_file.write("[") -json_file.write(json.dumps(get_license_info())) -json_file.write(", ") -json_file.write(json.dumps(spain.to_json())) -json_file.write(", ") -json_file.write(json.dumps(international.to_json())) -json_file.write(", ") -json_file.write(json.dumps(andorra.to_json())) -json_file.write("]") -json_file.close() -print("JSON Updated") - -# Save data to M3U8 file -text_file = open('./public/output/radio_channels.m3u8', "w+") -text_file.write("#EXTM3U" + "\n") -text_file.write("# @LaQuay https://github.com/LaQuay/TDTChannels" + "\n") -text_file.write(spain.to_m3u8()) -text_file.write(international.to_m3u8()) -text_file.write(andorra.to_m3u8()) -text_file.close() -print("M3U8 Updated") - -# Save data to M3U file -text_file = open('./public/output/radio_channels.m3u', "w+") -text_file.write("#EXTM3U" + "\n") -text_file.write("# @LaQuay https://github.com/LaQuay/TDTChannels" + "\n") -text_file.write(spain.to_m3u8()) -text_file.write(international.to_m3u8()) -text_file.write(andorra.to_m3u8()) -text_file.close() -print("M3U Updated") - -# Save data to .tv file (Enigma2) -# text_file = open('./public/output/userbouquet.tdtchannels.tv', "w+") -# text_file.write("#NAME @LaQuay https://github.com/LaQuay/TDTChannels" + "\n") -# text_file.write(spain.to_enigma2()) -# text_file.write(international.to_enigma2()) -# text_file.write(andorra.to_enigma2(() -# text_file.close() -# print("ENIGMA2 Updated") diff --git a/script/requirements.txt b/script/requirements.txt deleted file mode 100644 index 80247495..00000000 --- a/script/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -requests==2.21.0 \ No newline at end of file diff --git a/script/tv_script.py b/script/tv_script.py deleted file mode 100644 index 485a0ee3..00000000 --- a/script/tv_script.py +++ /dev/null @@ -1,204 +0,0 @@ -# coding=utf-8 -import json - -import requests - -from ambit import Ambito -from country import Country -from utils import stringbetween, get_tv_channels_from_part, get_license_info - -page = requests.get('https://raw.githubusercontent.com/LaQuay/TDTChannels/master/TELEVISION.md', - headers={'Cache-Control': 'no-cache'}) -content = str(page.text) - -print("Updating TV files") - -spain = Country("Spain") -andorra = Country("Andorra") -international = Country("International") - -content_nacional = stringbetween(content, "## Nacionales", "## Locales") -content_local = stringbetween(content, "## Locales", "## Internacionales") - -canales_nacionales = stringbetween(content_nacional, "", "## Informativos") -spain.add_ambit(Ambito("Generalistas", get_tv_channels_from_part(canales_nacionales))) - -canales_informativos = stringbetween(content_nacional, "## Informativos", "## Deportivos") -spain.add_ambit(Ambito("Informativos", get_tv_channels_from_part(canales_informativos))) - -canales_deportivos = stringbetween(content_nacional, "## Deportivos", "## Infantiles") -spain.add_ambit(Ambito("Deportivos", get_tv_channels_from_part(canales_deportivos))) - -canales_infantiles = stringbetween(content_nacional, "## Infantiles", "## Musicales") -spain.add_ambit(Ambito("Infantiles", get_tv_channels_from_part(canales_infantiles))) - -canales_musicales = stringbetween(content_nacional, "## Musicales", "## Webcams") -spain.add_ambit(Ambito("Musicales", get_tv_channels_from_part(canales_musicales))) - -canales_webcams = stringbetween(content_nacional, "## Webcams", "## Autonómicos") -spain.add_ambit(Ambito("Webcams", get_tv_channels_from_part(canales_webcams))) - -canales_autonomicos_andalucia = stringbetween(content_nacional, "### Andalucía", "### Aragón") -spain.add_ambit(Ambito("Andalucía", get_tv_channels_from_part(canales_autonomicos_andalucia))) - -canales_autonomicos_aragon = stringbetween(content_nacional, "### Aragón", "### Asturias") -spain.add_ambit(Ambito("Aragón", get_tv_channels_from_part(canales_autonomicos_aragon))) - -canales_autonomicos_asturias = stringbetween(content_nacional, "### Asturias", "### Canarias") -spain.add_ambit(Ambito("Asturias", get_tv_channels_from_part(canales_autonomicos_asturias))) - -canales_autonomicos_canarias = stringbetween(content_nacional, "### Canarias", "### Cantabria") -spain.add_ambit(Ambito("Canarias", get_tv_channels_from_part(canales_autonomicos_canarias))) - -canales_autonomicos_cantabria = stringbetween(content_nacional, "### Cantabria", "### Castilla La-Mancha") -spain.add_ambit(Ambito("Cantabria", get_tv_channels_from_part(canales_autonomicos_cantabria))) - -canales_autonomicos_castilla_mancha = stringbetween(content_nacional, "### Castilla La-Mancha", "### Castilla y León") -spain.add_ambit(Ambito("Castilla La-Mancha", get_tv_channels_from_part(canales_autonomicos_castilla_mancha))) - -canales_autonomicos_castilla_leon = stringbetween(content_nacional, "### Castilla y León", "### Cataluña") -spain.add_ambit(Ambito("Castilla y León", get_tv_channels_from_part(canales_autonomicos_castilla_leon))) - -canales_autonomicos_catalunya = stringbetween(content_nacional, "### Cataluña", "### Ceuta") -spain.add_ambit(Ambito("Cataluña", get_tv_channels_from_part(canales_autonomicos_catalunya))) - -canales_autonomicos_ceuta = stringbetween(content_nacional, "### Ceuta", "### Extremadura") -spain.add_ambit(Ambito("Ceuta", get_tv_channels_from_part(canales_autonomicos_ceuta))) - -canales_autonomicos_extremadura = stringbetween(content_nacional, "### Extremadura", "### Galicia") -spain.add_ambit(Ambito("Extremadura", get_tv_channels_from_part(canales_autonomicos_extremadura))) - -canales_autonomicos_galicia = stringbetween(content_nacional, "### Galicia", "### Islas Baleares") -spain.add_ambit(Ambito("Galicia", get_tv_channels_from_part(canales_autonomicos_galicia))) - -canales_autonomicos_islas_baleares = stringbetween(content_nacional, "### Islas Baleares", "### La Rioja") -spain.add_ambit(Ambito("Islas Baleares", get_tv_channels_from_part(canales_autonomicos_islas_baleares))) - -canales_autonomicos_la_rioja = stringbetween(content_nacional, "### La Rioja", "### Madrid") -spain.add_ambit(Ambito("La Rioja", get_tv_channels_from_part(canales_autonomicos_la_rioja))) - -canales_autonomicos_madrid = stringbetween(content_nacional, "### Madrid", "### Melilla") -spain.add_ambit(Ambito("Madrid", get_tv_channels_from_part(canales_autonomicos_madrid))) - -canales_autonomicos_melilla = stringbetween(content_nacional, "### Melilla", "### Murcia") -spain.add_ambit(Ambito("Melilla", get_tv_channels_from_part(canales_autonomicos_melilla))) - -canales_autonomicos_murcia = stringbetween(content_nacional, "### Murcia", "### Navarra") -spain.add_ambit(Ambito("Murcia", get_tv_channels_from_part(canales_autonomicos_murcia))) - -canales_autonomicos_navarra = stringbetween(content_nacional, "### Navarra", "### País Vasco") -spain.add_ambit(Ambito("Navarra", get_tv_channels_from_part(canales_autonomicos_navarra))) - -canales_autonomicos_pais_vasco = stringbetween(content_nacional, "### País Vasco", "### Valencia") -spain.add_ambit(Ambito("País Vasco", get_tv_channels_from_part(canales_autonomicos_pais_vasco))) - -canales_autonomicos_valencia = stringbetween(content_nacional, "### Valencia", "") -spain.add_ambit(Ambito("Valencia", get_tv_channels_from_part(canales_autonomicos_valencia))) - -canales_locales_andalucia = stringbetween(content_local, "### Andalucía", "### Aragón") -spain.get_ambit("Andalucía").add_channels(get_tv_channels_from_part(canales_locales_andalucia)) - -canales_locales_aragon = stringbetween(content_local, "### Aragón", "### Asturias") -spain.get_ambit("Aragón").add_channels(get_tv_channels_from_part(canales_locales_aragon)) - -canales_locales_asturias = stringbetween(content_local, "### Asturias", "### Canarias") -spain.get_ambit("Asturias").add_channels(get_tv_channels_from_part(canales_locales_asturias)) - -canales_locales_canarias = stringbetween(content_local, "### Canarias", "### Cantabria") -spain.get_ambit("Canarias").add_channels(get_tv_channels_from_part(canales_locales_canarias)) - -canales_locales_cantabria = stringbetween(content_local, "### Cantabria", "### Castilla La-Mancha") -spain.get_ambit("Cantabria").add_channels(get_tv_channels_from_part(canales_locales_cantabria)) - -canales_locales_castilla_mancha = stringbetween(content_local, "### Castilla La-Mancha", "### Castilla y León") -spain.get_ambit("Castilla La-Mancha").add_channels(get_tv_channels_from_part(canales_locales_castilla_mancha)) - -canales_locales_castilla_leon = stringbetween(content_local, "### Castilla y León", "### Cataluña") -spain.get_ambit("Castilla y León").add_channels(get_tv_channels_from_part(canales_locales_castilla_leon)) - -canales_locales_catalunya = stringbetween(content_local, "### Cataluña", "### Ceuta") -spain.get_ambit("Cataluña").add_channels(get_tv_channels_from_part(canales_locales_catalunya)) - -canales_locales_ceuta = stringbetween(content_local, "### Ceuta", "### Extremadura") -spain.get_ambit("Ceuta").add_channels(get_tv_channels_from_part(canales_locales_ceuta)) - -canales_locales_extremadura = stringbetween(content_local, "### Extremadura", "### Galicia") -spain.get_ambit("Extremadura").add_channels(get_tv_channels_from_part(canales_locales_extremadura)) - -canales_locales_galicia = stringbetween(content_local, "### Galicia", "### Islas Baleares") -spain.get_ambit("Galicia").add_channels(get_tv_channels_from_part(canales_locales_galicia)) - -canales_locales_islas_baleares = stringbetween(content_local, "### Islas Baleares", "### La Rioja") -spain.get_ambit("Islas Baleares").add_channels(get_tv_channels_from_part(canales_locales_islas_baleares)) - -canales_locales_la_rioja = stringbetween(content_local, "### La Rioja", "### Madrid") -spain.get_ambit("La Rioja").add_channels(get_tv_channels_from_part(canales_locales_la_rioja)) - -canales_locales_madrid = stringbetween(content_local, "### Madrid", "### Melilla") -spain.get_ambit("Madrid").add_channels(get_tv_channels_from_part(canales_locales_madrid)) - -canales_locales_melilla = stringbetween(content_local, "### Melilla", "### Murcia") -spain.get_ambit("Melilla").add_channels(get_tv_channels_from_part(canales_locales_melilla)) - -canales_locales_murcia = stringbetween(content_local, "### Murcia", "### Navarra") -spain.get_ambit("Murcia").add_channels(get_tv_channels_from_part(canales_locales_murcia)) - -canales_locales_navarra = stringbetween(content_local, "### Navarra", "### País Vasco") -spain.get_ambit("Navarra").add_channels(get_tv_channels_from_part(canales_locales_navarra)) - -canales_locales_pais_vasco = stringbetween(content_local, "### País Vasco", "### Valencia") -spain.get_ambit("País Vasco").add_channels(get_tv_channels_from_part(canales_locales_pais_vasco)) - -canales_locales_valencia = stringbetween(content_local, "### Valencia", "") -spain.get_ambit("Valencia").add_channels(get_tv_channels_from_part(canales_locales_valencia)) - -canales_internacionales = stringbetween(content, "## Internacionales", "## Andorra") -international.add_ambit(Ambito("Internacional", get_tv_channels_from_part(canales_internacionales))) - -canales_andorra = stringbetween(content, "## Andorra", "") -andorra.add_ambit(Ambito("Andorra", get_tv_channels_from_part(canales_andorra))) - -# Save data to JSON file -json_file = open('./public/output/channels.json', "w+") -json_file.write("[") -json_file.write(json.dumps(get_license_info())) -json_file.write(", ") -json_file.write(json.dumps(spain.to_json())) -json_file.write(", ") -json_file.write(json.dumps(international.to_json())) -json_file.write(", ") -json_file.write(json.dumps(andorra.to_json())) -json_file.write("]") -json_file.close() -print("JSON Updated") - -# Save data to M3U8 file -text_file = open('./public/output/channels.m3u8', "w+") -text_file.write("#EXTM3U @LaQuay https://github.com/LaQuay/TDTChannels" + "\n") -text_file.write( - "#EXTM3U url-tvg=\"https://raw.githubusercontent.com/HelmerLuzo/TDTChannels_EPG/master/TDTChannels_EPG.xml\"\n") -text_file.write(spain.to_m3u8()) -text_file.write(international.to_m3u8()) -text_file.write(andorra.to_m3u8()) -text_file.close() -print("M3U8 Updated") - -# Save data to M3U file -text_file = open('./public/output/channels.m3u', "w+") -text_file.write("#EXTM3U @LaQuay https://github.com/LaQuay/TDTChannels" + "\n") -text_file.write( - "#EXTM3U url-tvg=\"https://raw.githubusercontent.com/HelmerLuzo/TDTChannels_EPG/master/TDTChannels_EPG.xml\"\n") -text_file.write(spain.to_m3u8()) -text_file.write(international.to_m3u8()) -text_file.write(andorra.to_m3u8()) -text_file.close() -print("M3U Updated") - -# Save data to .tv file (Enigma2) -text_file = open('./public/output/userbouquet.tdtchannels.tv', "w+") -text_file.write("#NAME @LaQuay https://github.com/LaQuay/TDTChannels" + "\n") -text_file.write(spain.to_enigma2()) -text_file.write(international.to_enigma2()) -text_file.write(andorra.to_enigma2()) -text_file.close() -print("ENIGMA2 Updated") diff --git a/script/utils.py b/script/utils.py deleted file mode 100644 index ce73ae36..00000000 --- a/script/utils.py +++ /dev/null @@ -1,106 +0,0 @@ -import re - -from channel import Channel - - -def get_license_info(): - return { - "source": "https://github.com/LaQuay/TDTChannels", - "license": "https://github.com/LaQuay/TDTChannels/blob/master/LICENSE" - } - - -def stringbetween(text, start, end): - result = re.search('(?<=' + start + ')(.*)(?=' + end + ')', text, re.DOTALL) - return result.group(1) - - -def stringbetweenparantheses(text): - return text.split("(")[1].split(")")[0] - - -def get_tv_channels_from_part(text): - line_where_first_channel_starts = 15 - attributes_per_item = 6 - list_to_iterate = text.split("|")[line_where_first_channel_starts:-1] - while "\n" in list_to_iterate: - list_to_iterate.remove("\n") - channel_list = [] - for i in range(0, len(list_to_iterate), attributes_per_item): - item_name = list_to_iterate[i].strip() - - item_options = list_to_iterate[i + 1].strip() - - item_web = list_to_iterate[i + 2].strip() - if len(item_web) > 0 and item_web[0] != "-": - item_web = stringbetweenparantheses(item_web) - if len(item_web) == 1: - item_web = "" - - if "HD" in item_name: - item_resolution = "HD" - else: - item_resolution = "SD" - - item_logo = list_to_iterate[i + 3].strip() - if len(item_logo) > 0 and item_logo[0] != "-": - item_logo = stringbetweenparantheses(item_logo) - if len(item_logo) == 1: - item_logo = "" - - item_epg = list_to_iterate[i + 4].strip() - if len(item_epg) == 1: - item_epg = "" - - item_extra_info = list_to_iterate[i + 5].strip() - if len(item_extra_info) == 1: - item_extra_info = "" - - channel = Channel(item_name, item_web, item_resolution, item_logo, item_epg, item_extra_info) - item_options = item_options.split(" - ") - if len(item_options) > 0 and item_options[0] != "-": - for option in item_options: - format = (option[1:5]).replace("]", "") - url = stringbetweenparantheses(option) - channel.add_option(format, url) - channel_list.append(channel) - return channel_list - - -def get_radio_channels_from_part(text): - line_where_first_channel_starts = 13 - attributes_per_item = 5 - list_to_iterate = text.split("|")[line_where_first_channel_starts:-1] - while "\n" in list_to_iterate: - list_to_iterate.remove("\n") - channel_list = [] - for i in range(0, len(list_to_iterate), attributes_per_item): - item_name = list_to_iterate[i].strip() - - item_options = list_to_iterate[i + 1].strip() - - item_web = list_to_iterate[i + 2].strip() - if len(item_web) > 0 and item_web[0] != "-": - item_web = stringbetweenparantheses(item_web) - if len(item_web) == 1: - item_web = "" - - item_logo = list_to_iterate[i + 3].strip() - if len(item_logo) > 0 and item_logo[0] != "-": - item_logo = stringbetweenparantheses(item_logo) - if len(item_logo) == 1: - item_logo = "" - - item_extra_info = list_to_iterate[i + 4].strip() - if len(item_extra_info) == 1: - item_extra_info = "" - - channel = Channel(item_name, item_web, "", item_logo, "", item_extra_info) - item_options = item_options.split(" - ") - if len(item_options) > 0 and item_options[0] != "-": - for option in item_options: - format = (option[1:5]).replace("]", "") - url = stringbetweenparantheses(option) - channel.add_option(format, url) - channel_list.append(channel) - return channel_list