mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 12:05:35 +00:00
add audio download
This commit is contained in:
parent
fb892cc58d
commit
09b6e1203c
@ -3,10 +3,10 @@
|
|||||||
# Class import
|
# Class import
|
||||||
from Stream.util.headers import get_headers
|
from Stream.util.headers import get_headers
|
||||||
from Stream.util.console import console, msg, console_print
|
from Stream.util.console import console, msg, console_print
|
||||||
from Stream.util.m3u8 import dw_m3u8
|
from Stream.util.m3u8 import dw_m3u8, join_audio_to_video
|
||||||
|
|
||||||
# General import
|
# General import
|
||||||
import requests, sys, re, json
|
import requests, os, re, json
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
# [func]
|
# [func]
|
||||||
@ -64,6 +64,18 @@ def get_m3u8_key_ep(json_win_video, json_win_param, tv_name, n_stagione, n_ep, e
|
|||||||
|
|
||||||
return "".join(["{:02x}".format(c) for c in req_key])
|
return "".join(["{:02x}".format(c) for c in req_key])
|
||||||
|
|
||||||
|
def get_m3u8_audio(json_win_video, json_win_param, tv_name, n_stagione, n_ep, ep_title):
|
||||||
|
|
||||||
|
response = requests.get('https://vixcloud.co/playlist/175967', params={'token': json_win_param['token'], 'expires': json_win_param["expires"] }, headers={
|
||||||
|
'referer': f'https://vixcloud.co/embed/{json_win_video["id"]}?token={json_win_param["token720p"]}&title={tv_name.replace("-", "+")}&referer=1&expires={json_win_param["expires"]}&description=S{n_stagione}%3AE{n_ep}+{ep_title.replace(" ", "+")}&nextEpisode=1'
|
||||||
|
})
|
||||||
|
|
||||||
|
m3u8_cont = response.text.split()
|
||||||
|
for row in m3u8_cont:
|
||||||
|
if "audio" in str(row) and "ita" in str(row):
|
||||||
|
return row.split(",")[-1].split('"')[-2]
|
||||||
|
|
||||||
|
|
||||||
def main_dw_tv(tv_id, tv_name, version, domain):
|
def main_dw_tv(tv_id, tv_name, version, domain):
|
||||||
|
|
||||||
token = get_token(tv_id, domain)
|
token = get_token(tv_id, domain)
|
||||||
@ -84,3 +96,11 @@ def main_dw_tv(tv_id, tv_name, version, domain):
|
|||||||
|
|
||||||
dw_m3u8(m3u8_url, requests.get(m3u8_url, headers={"User-agent": get_headers()}).text, "", m3u8_key, tv_name.replace("+", "_") + "_"+str(season_select)+"__"+str(index_ep_select+1) + ".mp4")
|
dw_m3u8(m3u8_url, requests.get(m3u8_url, headers={"User-agent": get_headers()}).text, "", m3u8_key, tv_name.replace("+", "_") + "_"+str(season_select)+"__"+str(index_ep_select+1) + ".mp4")
|
||||||
|
|
||||||
|
is_down_audio = msg.ask("[blue]Download audio [red](!!! Only for recent upload, !!! Use all CPU) [blue][y \ n]").strip()
|
||||||
|
if str(is_down_audio) == "y":
|
||||||
|
m3u8_url_audio = get_m3u8_audio(json_win_video, json_win_param, tv_name, season_select, index_ep_select+1, eps[index_ep_select]['name'])
|
||||||
|
dw_m3u8(m3u8_url_audio, requests.get(m3u8_url_audio, headers={"User-agent": get_headers()}).text, "", m3u8_key, "audio.mp4")
|
||||||
|
|
||||||
|
join_audio_to_video("videos//audio.mp4", "videos//" + tv_name.replace("+", "_") + "_"+str(season_select)+"__"+str(index_ep_select+1) + ".mp4", "videos//" + tv_name.replace("+", "_") + "_"+str(season_select)+"__"+str(index_ep_select+1) + "_audio.mp4")
|
||||||
|
os.remove("videos//audio.mp4")
|
||||||
|
os.remove("videos//" + tv_name.replace("+", "_") + "_"+str(season_select)+"__"+str(index_ep_select+1) + ".mp4")
|
@ -5,6 +5,7 @@ import re, os, sys, glob, time, requests, shutil, ffmpeg, subprocess
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
from multiprocessing.dummy import Pool
|
from multiprocessing.dummy import Pool
|
||||||
from tqdm.rich import tqdm
|
from tqdm.rich import tqdm
|
||||||
|
import moviepy.editor as mp
|
||||||
|
|
||||||
# Class import
|
# Class import
|
||||||
#from Stream.util.console import console
|
#from Stream.util.console import console
|
||||||
@ -289,3 +290,11 @@ def dw_vvt_sub(url, headers, folder_id) -> (None):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
console.log("[red]Cant find info of subtitle [SKIP]")
|
console.log("[red]Cant find info of subtitle [SKIP]")
|
||||||
|
|
||||||
|
def join_audio_to_video(audio_path, video_path, out_path):
|
||||||
|
|
||||||
|
audio = mp.AudioFileClip(audio_path)
|
||||||
|
video1 = mp.VideoFileClip(video_path)
|
||||||
|
final = video1.set_audio(audio)
|
||||||
|
|
||||||
|
final.write_videofile(out_path)
|
@ -5,3 +5,4 @@ tqdm
|
|||||||
rich
|
rich
|
||||||
random-user-agent
|
random-user-agent
|
||||||
ffmpeg-python
|
ffmpeg-python
|
||||||
|
moviepy
|
Loading…
x
Reference in New Issue
Block a user