Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # www.stranck.ovh
- import youtube_dl
- import requests
- from guizero import App, Text, TextBox, PushButton
- from threading import Thread
- app = App(title="raiplay downloader", height=100)
- text = Text(app, text="Inserisci link del video su raiplay!")
- wpTBox = TextBox(app, width="fill")
- ready = True
- class DwnThread (Thread):
- def __init__(self, wpLink):
- Thread.__init__(self)
- self.wpLink = wpLink
- def run(self):
- try:
- wpLink = self.wpLink
- print("Ottenendo link m3u8... ", end="")
- text.value = "Ottenendo link m3u8..."
- jsonLink = wpLink.replace("html", "json")
- json = requests.get(jsonLink).json()
- m3u8Link = json["video"]["content_url"]
- print(m3u8Link, "Scaricando il video nella directory corrente", sep="\n")
- text.value = "Scaricando il video nella directory corrente..."
- options = {
- 'format': 'best',
- 'outtmpl': remove_chars(json["episode_title"], "*.\"\\/[]:;|,<>?") + ".mp4"
- }
- with youtube_dl.YoutubeDL(options) as ydl:
- ydl.download([m3u8Link])
- print("Scaricato!")
- text.value = "Scaricato! Inserisci un altro link di raiplay"
- except Exception as e:
- print(e)
- text.value = "Si è verificato un errore!"
- wpTBox.value = ""
- global ready
- ready = True
- def remove_chars(input_string, removable):
- return ''.join([_ for _ in input_string if _ not in removable])
- def download():
- global ready
- if(ready):
- ready = False #nice race condition
- dwn = DwnThread(wpTBox.value)
- dwn.start()
- PushButton(app, text="Scarica!", command=download)
- app.display()
RAW Paste Data
Copied