DaveBben / unofficial_tiktok_smartwatch

An unofficial TikTok smartwatch powered by the ESP32
https://www.youtube.com/watch?v=cla2Bhg6RE0
MIT License
19 stars 4 forks source link

you-get support #2

Closed modi12jin closed 1 year ago

modi12jin commented 1 year ago

You-Get is a tiny command-line utility to download media contents (videos, audios, images) from the Web, in case there is no other handy way to do it.

@DaveBben Hi! Can you support you-get? It supports multiple online video sites to download

simple_socket.py

import os
from you_get import common as you_get

f = open('video_list.text', 'r')

while 1:
    line = f.readline()
    if not line:
        break
    os.system("you-get --no-caption -o ./videos %s" % (line))
    pass

f.close()

video_list.text

https://www.bilibili.com/video/BV1ce4y1M7QZ
https://www.bilibili.com/video/BV1MP411T7ri
https://www.bilibili.com/video/BV17e4y1M7Qm
modi12jin commented 1 year ago
import flet as ft
import os
import you_get

def main(page: ft.Page):
    def button_clicked(e):
        os.system("you-get --no-caption -O 01 -o ./videos %s" % (tb1.value))
        command = "ffmpeg -y -i {} -vf 'fps=20,scale=480:-1:flags=lanczos' -q:v 9 {} -ar 44100 -ac 1 -ab 24k -filter:a loudnorm -filter:a 'volume=-5dB' {}".format('./videos/01.mp4','480_20fps.mjpeg','44100.aac')
        os.system(command)
        t.value = f"完成下载"
        page.update()

    t = ft.Text()
    tb1 = ft.TextField(label="请输入视频链接",hint_text="例如输入bilibili")
    b = ft.ElevatedButton(text="下载", on_click=button_clicked)
    page.add(tb1, b, t)

ft.app(target=main)
modi12jin commented 1 year ago

@DaveBben Looks like it's pretty simple to support, I've succeeded, I'll close this question

import you_get

def get_audio_video_info():

    item = random.randint(0, len(videos)-1)
    video_id = videos[item]

    filename = f"{uuid.uuid4()}.mp4"
    path = os.path.join(video_path, filename)
    os.system("you-get --no-caption -O %s -o ./videos %s" % (filename[:-4],video_id))

    # 将视频转换为20FPS。将音频输出到单独的文件
    command = "ffmpeg -y -i {} -filter:v fps=20 {} -filter:a 'volume=0.9' -ac 1 -ar 44100 {}".format(path, os.path.join(video_path, f"converted-{filename}"),'output.wav')
    os.system(command)
    items = [path, 'output.wav']
    return items

https://user-images.githubusercontent.com/40233017/208236690-69c64899-8b5c-4a60-bab7-6737ff1241ef.mp4