Spmart / YTAP-Bot

Telegram bot that downloads audio from YouTube and sends it to the user as an audio file.
MIT License
15 stars 2 forks source link

Video's title as audio's name #3

Open SilencerWeb opened 4 years ago

SilencerWeb commented 4 years ago

Currently, audio names are just numbers like 1234.m4a. Wouldn't it be better to set video's title as audio's name? It would be way more understandable

image

Spmart commented 4 years ago

Oh... I don't now how to solve this issue yet.

Bot keeps an audio files in subdir ./audio:

$ ls -la /var/www/telegrambots/ytap/audio/
итого 350184
drwxrwxr-x 2 ytap ytap     4096 июл 21 11:24 .
drwxr-xr-x 3 ytap ytap     4096 июн 28 14:38 ..
-rw-r--r-- 1 ytap ytap  3798122 апр  4 13:32 1419.m4a
-rw-r--r-- 1 ytap ytap 10722035 апр 21 01:45 1432.m4a
-rw-r--r-- 1 ytap ytap  3431170 янв 19  2020 1437.m4a
...
-rw-r--r-- 1 ytap ytap 20394177 фев 21  2015 1597.m4a
-rw-r--r-- 1 ytap ytap 44897986 мар  1  2019 1600.m4a
-rw-r--r-- 1 ytap ytap  1880912 июл 21 11:24 1605.m4a

Number is unique and incremental. It's a telegram message ID. Telegram API generates it and I shouldn't wory about generating unique filenames. That's why I use it.

I tried video title as a audio file name but file system paths brokes :( Title can include any unicode sequence. Some of them can be interpreted as escape sequences and paths... ./audio dir turns to chaos...

Also, Telegram API doesn't give a chance to change file name. Telegram sets name from your file system. On Telegram servers file stores with unique ID.

Filename is showing only in desktop client. On mobile (iOS) you see only title and other meta info.

IMG_6800