adithya-s-sekhar / advanced-youtube-client-ayc

AYC is a highly responsive, no nonsense, easy to use, fast video downloader from the text based era.
https://advanced-youtube-client-ayc.sourceforge.io/
GNU General Public License v3.0
109 stars 4 forks source link

Automatic naming of downloaded files - Incorrect Video ID #3

Closed MFrost98 closed 1 year ago

MFrost98 commented 1 year ago

The current naming convention is Title of Video-Format-Resolution-youtube video id

For example: "Apple's Forbidden Words-MP4-960p-kvN5_GXlg2"

Consistently, this auto-naming function has been incorrectly inserting the youtube video id at the end of the file name. In the above example, which I downloaded on June 23, 2023, the actual youtube video id is: _kvN5GXlg2Y

It appears that the files names are missing the last character of the youtube video id. Youtube video ID's are 11 characters long, while the inserted video IDs are only 10 characters long. I have tested this with over 30 different videos over the last few days and the result is the same. The last character of the video ID is missing. Further information can be provided as needed.

adithya-s-sekhar commented 1 year ago

I knew this would bite me back one day. This was a quick and dirty fix to get away with an aria2 bug and the funny way batch scripts works.

The reason it does this

Some people put their download folders really deep into some folder like D:\some folder\folder2\folder 3\....\folder5. It doesn't have to be this deep, but it'll soon run into windows' path length limit. That is around 230-240 characters.

Now when you download videos with long file names, it'll go over the limit and the download fails.

yt-dlp can handle long paths no problem, but aria2 will crash. It won't even tell you it's an aria2 bug unless you look at the log, the download just fails.

So I made a quick and dirty fix to reduce file name length instead to 128 characters because some one might still ignore any warnings and then use long paths.

This 128 was split into multiple parts to fit the file name to give maximum length to the video title. Some sites use ridiculously long quality ids (vimeo), others use the whole video title as the video id so double the file name. Video id is currently restricted to 10 characters.

I was not aware that people were using the script as an archive tool, that's amazing. Honestly the whole reason ids are in the file name was because some videos have the same title and I needed another quick fix so that windows won't complain the file already exists. I didn't think of this use case.

The solution

These file length options will be exposed in settings in the next version and the video id limit will be increased to 11. Also I'll remove file name length restrictions for non aria2 downloads.

If you want to remove the restrictions now, you can change the .10s value for id to just s in the following files. Or just increase the number 10 to any number you like. 999 or something. You can also change values for title, quality and height there.

Youtube Downloads

In scripts\downloader\downloader.bat under :downloaderTried label. It's from line number 175 to 178.

You can change file naming restrictions for h264, vp9, av1 and audio files there.

Non Youtube Downloads

Non youtube download name restrictions are in scripts\downloader\uni\uniHome.bat under :uniDownloadTried label at line 76.

Batch Downloads

In scripts\downloader\downloader.bat under :batchDownloaderTried label starting from line 493 to 497

Hope that helps. If you have any doubts feel free to ask.

MFrost98 commented 1 year ago

Thank you for the quick and amazingly detailed response. I can confirm that changing the .10s value to a different number worked. On a personal note, I found your github while adding the youtube-dl agent to my plex server so I can archive child-focused youtube videos for my 1-year old to watch without having to worry about ads with inappropriate stuff for a 1-year old. Those githubs seemed fairly popular, at least at the time I was viewing them, so I believe a fair number of users are using your tools for archival purposes. Your tool has been amazingly helpful in cataloging and organizing various youtube videos. For your information, the plex agent I use requires video ids to be in [videoid] format. So I simply use Bulk Rename Utility to replace the - at the beginning of the video id section with a [ and add a ] to the end of the file name. Using this plex scanner with the video id allows plex to pull the thumbnail, channel information, and video description from youtube's API to create a clean looking interface.

Unfortunately, I am not good when it comes to code, otherwise I would offer my help in creating that setting to adjust the file name length, but I really appreciate the work you are doing.

adithya-s-sekhar commented 1 year ago

+1 for bulk rename utility. You can probably change the output template to wrap the video id in square brackets.

Try changing -%%(id).10s to [%%(id).10s]. Don't forget the space before the opening square bracket. I can't test at the moment, it should work fine.

MFrost98 commented 1 year ago

Yup that worked! New line now looks like: MP4-%%(height).5sp [%%(id).15s].%%(ext)s

Thanks!

adithya-s-sekhar commented 1 year ago

Fixed with https://github.com/adithya-s-sekhar/advanced-youtube-client-ayc/commit/f0ea00c7f236ee163917a7beed69f363fca34b8b

With help from https://github.com/yt-dlp/yt-dlp/issues/7405

adithya-s-sekhar commented 1 year ago

Fixed in release https://github.com/adithya-s-sekhar/advanced-youtube-client-ayc/releases/tag/v4.1