Created
July 30, 2024 16:11
-
-
Save domiko96/85345d3197f766d643bc31daf60022fe to your computer and use it in GitHub Desktop.
OSS video download Python
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
| # Copy this to your home folder and have requests installed (pip install requests) | |
| import requests | |
| resp = requests.get("http://192.168.2.100:80/api/video") | |
| for video in resp.json(): | |
| file_name = video["dir"].replace("%2B", "+") + "_" + video["name"] | |
| url = f"http://192.168.2.100:80/api/video/{video['dir']}/{video['name']}" | |
| with requests.get(url, stream=True) as r: | |
| r.raise_for_status() | |
| with open("Downloads/" + file_name, "wb") as f: | |
| for chunk in r.iter_content(chunk_size=8192): | |
| f.write(chunk) | |
| print(f"Downloaded {file_name}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment