thumb, flower.yml

This commit is contained in:
BennyThink 2022-01-01 22:06:49 +08:00
parent 2bf68036d2
commit 21f06ea248
No known key found for this signature in database
GPG Key ID: 6CD0DBDA5235D481
5 changed files with 37 additions and 16 deletions

View File

@ -39,3 +39,14 @@ services:
volumes:
- ./data/instagram.com_cookies.txt:/ytdlbot/ytdlbot/instagram.com_cookies.txt
- ./data/vnstat/:/var/lib/vnstat/
flower:
image: bennythink/ytdlbot
env_file:
- env/ytdl.env
restart: on-failure
command: [ "/usr/local/bin/celery" ,"-A","flower_tasks","flower" ,"--basic_auth=benny:123456","--address=0.0.0.0" ]
volumes:
- ./data/instagram.com_cookies.txt:/ytdlbot/ytdlbot/instagram.com_cookies.txt
ports:
- "5555:5555"

View File

@ -1,13 +0,0 @@
version: '3.1'
services:
flower:
image: bennythink/ytdlbot
env_file:
- env/ytdl.env
restart: always
command: [ "/usr/local/bin/celery" ,"-A","tasks","flower" ,"--basic_auth=benny:123456","--address=0.0.0.0" ]
volumes:
- ./data/instagram.com_cookies.txt:/ytdlbot/ytdlbot/instagram.com_cookies.txt
ports:
- "5555:5555"

15
ytdlbot/flower_tasks.py Normal file
View File

@ -0,0 +1,15 @@
#!/usr/local/bin/python3
# coding: utf-8
# ytdlbot - flower_tasks.py
# 1/2/22 10:17
#
__author__ = "Benny <benny.think@gmail.com>"
from celery import Celery
from config import BROKER
app = Celery('tasks', broker=BROKER)

View File

@ -22,7 +22,8 @@ from config import BROKER, ENABLE_CELERY, WORKERS
from constant import BotText
from db import Redis
from downloader import sizeof_fmt, upload_hook, ytdl_download
from utils import get_metadata, get_user_settings, customize_logger, apply_log_formatter
from utils import (apply_log_formatter, customize_logger, get_metadata,
get_user_settings)
customize_logger(["pyrogram.client", "pyrogram.session.session", "pyrogram.connection.connection"])
apply_log_formatter()

View File

@ -8,6 +8,8 @@
__author__ = "Benny <benny.think@gmail.com>"
import logging
import pathlib
import uuid
import ffmpeg
@ -85,6 +87,11 @@ def get_metadata(video_path):
except Exception as e:
logging.error(e)
thumb = video_path + "-thunmnail.png"
thumb = pathlib.Path(video_path).parent.joinpath(f"{uuid.uuid4().hex}-thunmnail.png").as_posix()
ffmpeg.input(video_path, ss=duration / 2).filter('scale', width, -1).output(thumb, vframes=1).run()
return dict(height=height, width=width, duration=duration, thumb=thumb)
return dict(height=height, width=width, duration=duration, thumb=thumb)
if __name__ == '__main__':
v = "/Users/benny/Movies/vlc-record-2021-02-27-21h17m53s-逃避可耻却有用 人类加油!新春特别篇!!.NIGERUHA.HAJIDAGA.YAKUNITATSU.Ganbare.Jinrui.Shinshun.Special.SP.Chi_Jap.HDTVrip.1280X720.mp4-.mp4"
get_metadata(v)