1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| import os import subprocess from datetime import datetime
telegram_stickers_dir = os.path.join(os.path.expanduser('~'), 'Desktop', 'telegram_stickers') telegram_token = <token>
input_dir = os.path.join(telegram_stickers_dir, 'original')
current_time = datetime.now().strftime('%Y-%m-%d_%H-%M-%S') archive_dir = os.path.join(telegram_stickers_dir, f'archive_{current_time}')
import shutil if os.path.exists(input_dir): shutil.rmtree(input_dir)
url = input("输入链接:")
os.system(f'sticker-convert --no-confirm --download-auto {url} --telegram-token {telegram_token} --output-dir {input_dir} --preset auto')
output_dir = os.path.join(telegram_stickers_dir, url.split('/')[-1]) os.makedirs(output_dir, exist_ok=True)
for filename in os.listdir(input_dir): if filename.endswith('.webp'): input_path = os.path.join(input_dir, filename) output_path = os.path.join(output_dir, f'{os.path.splitext(filename)[0]}.png') subprocess.run(['ffmpeg', '-i', input_path, output_path, '-y']) elif filename.endswith('.webm'): input_path = os.path.join(input_dir, filename) output_path = os.path.join(output_dir, f'{os.path.splitext(filename)[0]}.gif') subprocess.run(['ffmpeg', '-i', input_path, output_path, '-y'])
|