-
-
Save akash-gajjar/24fc183f6b25c74750606606f2319d01 to your computer and use it in GitHub Desktop.
| from datetime import datetime | |
| from os import system | |
| import requests | |
| import json | |
| ## 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/64145828ced74b0013d496ce/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 | |
| url = input("Please paste the URL of the meeting you want to download: ") | |
| meeting_id = url.split("/")[-1] | |
| print("\rFound meeting ID: ", meeting_id) | |
| auth_token = input("Auth token: ") | |
| data = requests.get( | |
| f"https://gw.tldv.io/v1/meetings/{meeting_id}/watch-page?noTranscript=true", | |
| headers={ | |
| "Authorization": auth_token, | |
| }, | |
| ) | |
| try: | |
| response = json.loads(data.text) | |
| meeting = response.get("meeting", {}) | |
| name = meeting.get("name", "No name") | |
| createdAt = meeting.get("createdAt", datetime.now()) | |
| source = response.get("video", {}).get("source", None) | |
| date = datetime.strptime((createdAt), "%Y-%m-%dT%H:%M:%S.%fZ") | |
| normalised_date = date.strftime("%Y-%m-%d-%H-%M-%S") | |
| filename = f"{normalised_date}_{name}" | |
| filename_ext = ".mp4" | |
| command = f'ffmpeg -i {source} -c copy "{filename}.{filename_ext}"' | |
| json_filename = f'{filename}.json' | |
| with open(json_filename, "w") as f: | |
| f.write(data.text) | |
| print(command) | |
| print("Downloading video...") | |
| system(command) | |
| except: | |
| print("Error encountered") | |
| print(data.text) |
Works like a charm! I added a fork with parallel downloading in case you need to download and process multiple at a time. I obtained links with selenium, and then made a list of videos. The MAX_WORKERS are basically the number of parallel videos to download and process. This makes the process way much faster.
I've used this from javier-ortizt
I'm a newbie here, but I'm so glad I got it to work haha! Basically, I installed ffmpeg on my Mac using Homebrew (I followed this tutorial) and once it's set up, I ran the command
python3 tldv.py
Thanks so much!!
Note: If you feel ffmpeg is too slow when downloading .m3u8 videos chunk by chunk β try this faster version using N_m3u8DL-RE, which supports parallel segment downloading and auto-merging.
WIndows Version
Download N_m3u8DL-RE.exe:
π https://github.com/nilaoda/N_m3u8DL-RE/releases
Then run this script to download TLDV meetings more faster:
from datetime import datetime
from os import system
import requests
import json
url = input("Please paste the URL of the meeting you want to download: ")
meeting_id = url.split("/")[-1].split("?")[0]
print("\rFound meeting ID: ", meeting_id)
auth_token = input("Auth token: ")
data = requests.get(
f"https://gw.tldv.io/v1/meetings/{meeting_id}/watch-page?noTranscript=true",
headers={"Authorization": auth_token},
)
try:
response = json.loads(data.text)
meeting = response.get("meeting", {})
name = meeting.get("name", "No name")
createdAt = meeting.get("createdAt", datetime.now())
source = response.get("video", {}).get("source", None)
date = datetime.strptime((createdAt), "%Y-%m-%dT%H:%M:%S.%fZ")
normalised_date = date.strftime("%Y-%m-%d-%H-%M-%S")
filename = f"{normalised_date}_{name}"
command = f'N_m3u8DL-RE.exe "{source}" --save-dir "." --save-name "{filename}" --thread-count 16 --del-after-done'
print(command)
print("Downloading video...")
system(command)
with open(f"{filename}.json", "w") as f:
f.write(data.text)
except Exception as e:
print("Error encountered")
print("Exception:", str(e))
print("Raw response:")
print(data.text)This script:
- Uses
N_m3u8DL-REto download in parallel (much faster than ffmpeg)
Created this dynamic script if anyone requires:
import os
import re
import json
import requests
from datetime import datetime
from subprocess import run, CalledProcessError
from tqdm import tqdm
#open cmd and type pip3 install requests tqdm
--- Helper Functions ---
def sanitize_filename(name):
return re.sub(r'[\/*?:"<>|]', "_", name)
def get_meeting_id(url):
return url.rstrip("/").split("/")[-1]
def fetch_meeting_data(meeting_id, auth_token):
api_url = f"https://gw.tldv.io/v1/meetings/{meeting_id}/watch-page?noTranscript=true"
response = requests.get(api_url, headers={"Authorization": auth_token})
response.raise_for_status()
return response.json()
def download_video(source_url, output_file):
command = [
"ffmpeg",
"-i", source_url,
"-c", "copy",
output_file
]
try:
run(command, check=True)
print(f"\nβ Download completed: {output_file}")
except CalledProcessError as e:
print("\nβ Error during download.")
print(e)
--- Main Logic ---
def main():
print("π₯ TLDV Video Downloader")
--- Run ---
if name == "main":
main()