Compare commits
5
Commits
f40c364c90
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37f9314312 | ||
|
|
a2df050dcb | ||
|
|
e8761e38ac | ||
|
|
30956cbbed | ||
|
|
2e3ac00dfa |
@@ -1,19 +1,19 @@
|
|||||||
from dataclasses import dataclass
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import time
|
||||||
|
import typing as tp
|
||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
import typing as tp
|
|
||||||
import time
|
|
||||||
from tqdm import tqdm
|
|
||||||
|
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.webdriver.common.keys import Keys
|
|
||||||
from selenium.webdriver.support.ui import WebDriverWait
|
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
|
from selenium.webdriver.common.keys import Keys
|
||||||
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
|
from tqdm import tqdm
|
||||||
|
|
||||||
import settings
|
import settings
|
||||||
|
|
||||||
@@ -95,9 +95,7 @@ def get_video_info(link: str) -> CoubVideo:
|
|||||||
|
|
||||||
info = get_json_from_page(data)
|
info = get_json_from_page(data)
|
||||||
try:
|
try:
|
||||||
title = "".join(x for x in info.get('title') if (x.isalnum() or x in "._- "))
|
title = link.split("/view/")[-1].replace('\n', '') + "_" + "".join(x for x in info.get('title') if (x.isalnum() or x in "._- "))
|
||||||
if len(title) < 1:
|
|
||||||
title = link.split("/view/")[-1]
|
|
||||||
video = info['file_versions']['html5']['video']
|
video = info['file_versions']['html5']['video']
|
||||||
video = video.get('higher') or video.get('high')
|
video = video.get('higher') or video.get('high')
|
||||||
audio = info['file_versions']['html5'].get('audio')
|
audio = info['file_versions']['html5'].get('audio')
|
||||||
@@ -158,8 +156,8 @@ def download_video(video: CoubVideo):
|
|||||||
|
|
||||||
print(video.title)
|
print(video.title)
|
||||||
save(http_get(video.video_url).content, video.title, "mp4")
|
save(http_get(video.video_url).content, video.title, "mp4")
|
||||||
save(http_get(video.audio_url).content, video.title, "mp3")
|
|
||||||
if video.audio_url:
|
if video.audio_url:
|
||||||
|
save(http_get(video.audio_url).content, video.title, "mp3")
|
||||||
execute_ffmpeg(video.title)
|
execute_ffmpeg(video.title)
|
||||||
else:
|
else:
|
||||||
shutil.copy(f"{settings.TEMP_DIR}/{video.title}.mp4", f"{settings.OUT_DIR}/{video.title}.mp4")
|
shutil.copy(f"{settings.TEMP_DIR}/{video.title}.mp4", f"{settings.OUT_DIR}/{video.title}.mp4")
|
||||||
|
|||||||
@@ -37,7 +37,10 @@ for video in videos:
|
|||||||
|
|
||||||
print("Removing temporary files...")
|
print("Removing temporary files...")
|
||||||
for item in os.listdir(settings.TEMP_DIR):
|
for item in os.listdir(settings.TEMP_DIR):
|
||||||
os.remove(item)
|
try:
|
||||||
|
os.remove(item)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
print("Done.")
|
print("Done.")
|
||||||
Reference in New Issue
Block a user