Add possibility to rename downloaded file #495
Hi,
I tried to enable the possibility to rename a file to a user specific name (but keep the extension) #495. I used customNamePrefix as a template and added the new optional advanced option customName`.
I tried to keep the changes as small as possible and tested different scenarios on my dev machine.
Does this PR matches your requested code quality?
Best, Bjoern
@Bjoernsen there are a few comments from copilot, I resolved what isn't relevant in my opinion but the rest are relevant. See if you can take a look? In general, how is it intended to work with playlists?
@alexta69 I will try to fix the comments from copilot.
Unfortunately, I have no clue regarding the playlist. Never used it :smirk: But I will have a look.
I tried to fix some of the copilot comments. Furthermore, I added a sanitize method.
Regarding the playlist, I do not understand what is going on. I add an URL that should be downloaded and set the custom_name to 'Some episode S02E04'.
output = playlist_output.replace('%(title)s', dl.custom_name) in line line 389 has been be called. I recognized it because the suggested change output = playlist_output.replace('%(title)s', f"{dl.custom_name} - %(playlist_index)s") added a - 1 to my custon_name.
Why is the playlist part triggered and not line 374?
I tried to do it in your branch and all the entries got the same name, which led to conflicts and the downloads failing. I'm not sure that there's a way to solve this that makes sense. That's one of the main reasons I'm not sure that this feature really belongs in MeTube.. Playlist are kind of one of the main use cases here.
I tried to modify the code a bit more. But because of the lack of a playlist, I am not able to test it. It should add an ID to the the file name, if there are multiple entries available.
But I am not sure if it is a big issue if it does not work and the files would be overwritten. There could be a BIG hint not to use custom_name in combination with playlists. Or it could be ignored if a playlist has been selected. Most users never ask for and and will not make use of this function. Because it is 'hidden' in the advanced settings, they should know what they are doing.
Unfortunately, my vacations are nearly over and because of lack of time, I am not sure if I am able to further modify the code.
It is you repo/project, it is your decision. It is OK for me if you decide not to add this function.