mirror of
https://github.com/LaQuay/TDTChannels.git
synced 2024-11-22 00:43:24 +01:00
test commit
This commit is contained in:
parent
bae97b8a8a
commit
a08ff9d63b
13 changed files with 2 additions and 1082 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
venv/
|
||||
.idea/
|
||||
__pycache__/
|
||||
script/public/output/
|
||||
script/public/output/
|
||||
script
|
|
@ -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
|
|
@ -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
|
||||
}
|
|
@ -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__()
|
|
@ -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();
|
|
@ -1,133 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>TDT Channels - Marc Vila</title>
|
||||
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-27327609-3"></script>
|
||||
<script src="./analytics.js"></script>
|
||||
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/clappr@latest/dist/clappr.min.js"></script>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
|
||||
|
||||
<script src="./index.js"></script>
|
||||
<link href="./styles.css" rel="stylesheet" type="text/css">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
<body>
|
||||
<div id="container" class="container" style="margin-top: 30px">
|
||||
<h1 id="titleh1" class="display-4">TDTChannels</h1>
|
||||
<br>
|
||||
<a class="btn btn-outline-secondary" role="button" href="https://github.com/LaQuay/TDTChannels"
|
||||
target="_blank">Repositorio TDT Channels</a>
|
||||
<a class="btn btn-outline-success" role="button" href="http://www.marcvila.me/"
|
||||
target="_blank">Marc Vila</a>
|
||||
<a class="btn btn-outline-warning" role="button" href="https://github.com/LaQuay/"
|
||||
target="_blank">GitHub</a>
|
||||
<a class="btn btn-outline-primary" role="button" href="https://www.linkedin.com/in/marcvilagomez/"
|
||||
target="_blank">LinkedIn</a>
|
||||
<div class="row" style="margin-top: 40px;">
|
||||
<div class="col-xs-4 col-md-4">
|
||||
<input id="searchInput" class="form-control" type="text" onkeyup="filterChannelsList()"
|
||||
placeholder="Search..." style="margin-bottom: 1px">
|
||||
<div id="channel-list" class="list-group channels-list"></div>
|
||||
</div>
|
||||
<div class="col-xs-8 col-md-8">
|
||||
<div id="video">
|
||||
<p class="lead">
|
||||
Reproductor de Televisión
|
||||
</p>
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<input id="input-reproduccion-video" type="text" class="form-control"
|
||||
placeholder="URL de reproducción">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-outline-secondary" type="button" id="button-reproduccion-video"
|
||||
onclick="loadItem('video');">Cargar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="video-player"></div>
|
||||
<div id="video-information" class="shadow-sm p-3 mb-5 bg-white rounded" style="margin-top: 15px">
|
||||
<p class="lead">Información de la reproducción</p>
|
||||
Formatos soportados
|
||||
<br>
|
||||
<em>m3u8</em>
|
||||
<br><br>
|
||||
Resoluciones disponibles
|
||||
<br>
|
||||
<em id="video-resolution"></em>
|
||||
<p id="extra-video-info" style="display: block"></p>
|
||||
<div id="option-buttons"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="audio" style="margin-top: 15px">
|
||||
<p class="lead">
|
||||
Reproductor de Radio
|
||||
</p>
|
||||
<div class="input-group mb-3">
|
||||
<input id="input-reproduccion-audio" type="text" class="form-control"
|
||||
placeholder="URL de reproducción">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-outline-secondary" type="button" id="button-reproduccion-audio"
|
||||
onclick="loadItem('audio');">Cargar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<audio id="audio-controller" controls autoplay="">
|
||||
<source id="audio-player" src="" type="audio/mpeg">
|
||||
Your browser does not support the audio element.
|
||||
</audio>
|
||||
<div id="audio-information" class="shadow-sm p-3 mb-5 bg-white rounded" style="margin-top: 15px">
|
||||
<p class="lead">Información de la reproducción</p>
|
||||
Formatos soportados
|
||||
<br>
|
||||
<em>aac</em>, <em>mp3</em>, <em>nsv</em>, <em>audio/mpeg</em>, <em>pls</em>(Beta)
|
||||
|
||||
<div id="extra-audio-info-div" style="display: none; padding-top: 20px">
|
||||
<button class="btn btn-secondary" type="button" data-toggle="collapse"
|
||||
data-target="#collapseAlternativas"
|
||||
aria-expanded="false" aria-controls="collapseAlternativas">
|
||||
URLs alternativas
|
||||
</button>
|
||||
<div class="collapse" id="collapseAlternativas">
|
||||
<div class="card card-body">
|
||||
<p id="extra-audio-info"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="navbar fixed-bottom container">
|
||||
<div class="alert alert-warning alert-dismissible fade show" role="alert">
|
||||
<em><strong>Nota</strong>: Esta web está diseñada únicamente para comprobar el funcionamiento con los canales
|
||||
del repositorio. Queda fuera del objetivo algún otro uso. El usuario es el responsable del
|
||||
uso que se le da a la web.</em>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var player;
|
||||
|
||||
var typeToReproduce = getUrlParameter("type");
|
||||
var channelToReproduce;
|
||||
if (typeToReproduce == "audio") {
|
||||
channelToReproduce = getUrlParameter("channel");
|
||||
reproduceAudio(channelToReproduce);
|
||||
} else if (typeToReproduce == "video") {
|
||||
channelToReproduce = getUrlParameter("channel");
|
||||
reproduceVideo(channelToReproduce);
|
||||
}
|
||||
|
||||
loadChannelsInList();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -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] + "<br>";
|
||||
}
|
||||
}
|
||||
|
||||
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 +=
|
||||
"<a href='javascript:reproduceVideo(\"" + url + "\")' class='btn btn-secondary btn-sm' style='margin-right: 10px'>Opción " + (i+1) + "</a>";
|
||||
}
|
||||
}
|
||||
} 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("<a href='javascript:onChannelClick(" + JSON.stringify(JSON.stringify(val)) + ")' class='list-group-item list-group-item-action'>" + val["name"] + "</a>")
|
||||
});
|
||||
});
|
||||
|
||||
$(items.join( "" )).appendTo(".channels-list");
|
||||
});
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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")
|
|
@ -1 +0,0 @@
|
|||
requests==2.21.0
|
|
@ -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")
|
106
script/utils.py
106
script/utils.py
|
@ -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
|
Loading…
Reference in a new issue