Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e0459c6d7 | ||
|
|
7b7116dd16 | ||
|
|
e5e0e97858 | ||
|
|
83303b3548 |
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
@@ -1,49 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
import requests
|
|
||||||
import os
|
|
||||||
import time
|
|
||||||
import csv
|
|
||||||
|
|
||||||
import linux
|
|
||||||
from database import Database
|
|
||||||
|
|
||||||
CHANNEL_NAME = 'teampgp'
|
|
||||||
DB = None
|
|
||||||
|
|
||||||
def write_csv(data, file_name):
|
|
||||||
# Open file with newline='' to prevent extra blank rows across platforms
|
|
||||||
with open(file_name, "w", newline="", encoding="utf-8") as file:
|
|
||||||
writer = csv.writer(file)
|
|
||||||
|
|
||||||
# Write all rows at once
|
|
||||||
writer.writerows(data)
|
|
||||||
|
|
||||||
def download():
|
|
||||||
"""Find all undownload videos and download them."""
|
|
||||||
undownloaded = DB.get_undownloaded()
|
|
||||||
|
|
||||||
print(f"Download...")
|
|
||||||
for id, title, created_at, view_count, duration, url, thumbnail_url, game_id, game_name, stream_id, creator_name, clip_is, downloaded, uploaded_yt, uploaded_yt_chats, uploaded_yt_shorts in undownloaded:
|
|
||||||
data = [[id, title, created_at, view_count, duration, url, thumbnail_url, game_id, game_name, stream_id, creator_name, clip_is, downloaded, uploaded_yt, uploaded_yt_chats, uploaded_yt_shorts]]
|
|
||||||
print(f"ID: {id} | Date: {created_at} | Game: {game_name} | Title: {title}")
|
|
||||||
if not clip_is:
|
|
||||||
output = linux.run_command(f"TwitchDownloaderCLI videodownload --id {id} -o download/videos/{id}/{id}.mp4 --collision Overwrite")
|
|
||||||
output2 = linux.run_command(f"TwitchDownloaderCLI chatdownload --id {id} -o download/videos/{id}/{id}_chat.json -E --collision Overwrite")
|
|
||||||
write_csv(data, f"download/videos/{id}/{id}.csv")
|
|
||||||
elif clip_is:
|
|
||||||
output = linux.run_command(f"TwitchDownloaderCLI clipdownload --id {id} -o download/clips/{id}/{id}.mp4 --collision Overwrite")
|
|
||||||
write_csv(data, f"download/clips/{id}/{id}.csv")
|
|
||||||
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
if output["success"] is True:
|
|
||||||
print(f"ID: {id} | Date: {created_at} | Game: {game_name} | Title: {title} | was successful")
|
|
||||||
DB.mark_as_downloaded(id)
|
|
||||||
else:
|
|
||||||
print(f"ID: {id} | Download Process failed. {output["stdout"]}. Error: {output["stderr"]}")
|
|
||||||
|
|
||||||
print(f"Finished Downloading...")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
DB = Database()
|
|
||||||
download()
|
|
||||||
Executable → Regular
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"client_id": "yr610ucde5vlae3zqniv23eps4ky7j",
|
||||||
|
"client_secret": "1m8bopo5hwtnv0mox9wql8i33fqrgr",
|
||||||
|
"manual_token": "dkmhv4f6k0mr1yyzof54xqll5pf7l3"
|
||||||
|
}
|
||||||
Executable → Regular
-1
@@ -1,4 +1,3 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import httpx # Switched from requests to prevent async loop freezing
|
import httpx # Switched from requests to prevent async loop freezing
|
||||||
|
|||||||
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Reference in New Issue
Block a user