Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
83f7bbead8 | ||
|
|
1257a15eb9 | ||
|
|
765eaf5026 | ||
|
|
4934ddb3f8 | ||
|
|
c8d12469e3 | ||
|
|
81e76b25d0 |
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Executable
+49
@@ -0,0 +1,49 @@
|
||||
#!/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()
|
||||
Regular → Executable
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"client_id": "yr610ucde5vlae3zqniv23eps4ky7j",
|
||||
"client_secret": "1m8bopo5hwtnv0mox9wql8i33fqrgr",
|
||||
"manual_token": "dkmhv4f6k0mr1yyzof54xqll5pf7l3"
|
||||
}
|
||||
Regular → Executable
+1
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
import asyncio
|
||||
import json
|
||||
import httpx # Switched from requests to prevent async loop freezing
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Reference in New Issue
Block a user