-
-
Save javier-ortizt/9532f82b3c633c0294be7c161124ec96 to your computer and use it in GitHub Desktop.
Download videos from TLDV.io
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| import json | |
| import re | |
| import os | |
| from datetime import datetime | |
| from os import system | |
| import traceback as tb | |
| from concurrent.futures import ThreadPoolExecutor, as_completed | |
| MAX_WORKERS = 5 | |
| OUTPUT_DIR = "output" | |
| AUTH_TOKEN = "Bearer TOKEN_HERE" | |
| HEADERS = { | |
| "Authorization": AUTH_TOKEN | |
| } | |
| meeting_urls = ['https://tldv.io/app/meetings/xxxxxxxxxxxxxxxxxxxxxxxx', | |
| 'https://tldv.io/app/meetings/yyyyyyyyyyyyyyyyyyyyyyyy'] | |
| def sanitize_filename(name): | |
| return re.sub(r'[\\/*?:"<>|]', "", name) | |
| def download_meeting(meeting_url): | |
| try: | |
| meeting_id = meeting_url.split("/")[-1].split("?")[0] | |
| print(f"\nIniciando: {meeting_id}") | |
| api_url = f"https://gw.tldv.io/v1/meetings/{meeting_id}/watch-page?noTranscript=true" | |
| response = requests.get(api_url, headers=HEADERS) | |
| data = response.json() | |
| meeting = data.get("meeting", {}) | |
| name = meeting.get("name", "No name") | |
| createdAt = meeting.get("createdAt", datetime.now().isoformat()) | |
| source = data.get("video", {}).get("source") | |
| if not source: | |
| raise ValueError("URL del video no encontrada") | |
| date = datetime.strptime(createdAt, "%Y-%m-%dT%H:%M:%S.%fZ") | |
| filename_base = f"{date.strftime('%Y-%m-%d-%H-%M-%S')}_{sanitize_filename(name)}" | |
| json_file = os.path.join(OUTPUT_DIR, f"{filename_base}.json") | |
| output_file = os.path.join(OUTPUT_DIR, f"{filename_base}.mp4") | |
| # Crea directorio si no existe (por seguridad en entorno multithread) | |
| os.makedirs(os.path.dirname(json_file), exist_ok=True) | |
| with open(json_file, "w", encoding="utf-8") as f: | |
| json.dump(data, f, ensure_ascii=False, indent=2) | |
| command = ( | |
| f'ffmpeg -y ' | |
| f'-protocol_whitelist file,http,https,tcp,tls ' | |
| f'-user_agent "Mozilla/5.0" ' | |
| f'-http_persistent 1 ' | |
| f'-headers "Authorization: {AUTH_TOKEN}\\r\\n" ' | |
| f'-i "{source}" -c copy "{output_file}"' | |
| ) | |
| print(f"[{meeting_id}] Ejecutando ffmpeg...") | |
| system(command) | |
| print(f"[{meeting_id}] Completado") | |
| return True | |
| except Exception as e: | |
| print(f"Error en {meeting_url}: {e}") | |
| tb.print_exc() | |
| return False | |
| def main(): | |
| os.makedirs(OUTPUT_DIR, exist_ok=True) | |
| os.chdir(OUTPUT_DIR) | |
| with ThreadPoolExecutor(max_workers=MAX_WORKERS) as executor: | |
| futures = [executor.submit(download_meeting, url) for url in meeting_urls] | |
| for future in as_completed(futures): | |
| future.result() | |
| if __name__ == "__main__": | |
| main() | |
| ## Please install ffmpeg before running this script and make sure it's in your PATH | |
| ## brew install ffmpeg | |
| ## Please install requests before running this script | |
| ## pip3 install requests | |
| ## download video from tldv.io | |
| ## | |
| ## 1. Go to https://tldv.io/ | |
| ## 2. Login | |
| ## 3. Go to the meeting you want to download | |
| ## 4. Copy the URL of the meeting | |
| ## 5. Open the developer tools (F12) | |
| ## 6. Go to the network tab | |
| ## 7. Refresh the page | |
| ## 8. Find the request to https://gw.tldv.io/v1/meetings/xxxxxxxxxxxxxxxxxxxxxxxx/watch-page?noTranscript=true | |
| ## 9. Copy the auth token from the request headers | |
| ## 10. Run this script and paste the URL and auth token | |
| ## 11. python3 tldv.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment