I'm using youtube_dl to create an mp3 converter for youtube. It works great, however, when I download a song the file gets lost in my downloads folder rather than being at the top/most recent thing I downloaded. When I check the files "Date Modified" metadata, it shows me some date from the past which I'm assuming is the original video's file and this causes the placement of the mp3 file in my downloads folder to be in some random spot rather than the top. So I want to see if there's a way to change a file's "Date Modified" time to when it was created since the "Date Created" is the time at which the file was converted and downloaded (i.e it's what it's supposed to be).
Is there a way to do this before I download the file or is this something I have to do once the file is already downloaded? Here's part of what I have to download an mp3 file
url = input("Enter the youtube link you want to download: ")
ydl_opts = {
'format': 'bestaudio/best',
'outtmpl': f'{downloads_path}/%(title)s.%(ext)s',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
'noplaylist': True
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([url])
print("Download is complete!")
To update a file's last modified timestamp to right now, you could use the unix command "touch", or use python alternatives like mentioned in this answer: Implement touch using Python?