I am making a YouTube downloader and i have come to a problem that i do not understand how to fix. Basically, you select which YouTube videos you want to download and it adds it to a queue. After they are downloaded i have used the MP4File .dll to write the mp4 metadata tags.
Most of the YouTube downloads and the metadata tags work but i think when the YouTube title contains symbols it doesn't change the metadata tags and instead just crashes.
I have debugged the program and found the problem within this method:
public static void UpdateMP4Details(string path, string title, string imagePreview)
{
try
{
MP4File file = MP4File.Open(@path); // Something wrong with the path
file.Tags.Title = title; // Crashes here
file.Tags.Artist = "Youtube";
file.Tags.Artwork = DownloadImageFromUrl(imagePreview);
file.Save();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "\n\nUnable to save video details", title);
}
}
The error i get is: 'Object reference not set to an instance of an object' i believe this is because it cannot find the path due to the symbols.
Sometimes the error is: 'Must specify a valid file name' Path:
"C:\Users\MyUserName\Documents\Visual Studio 2015\Projects\MusicDownloader\MusicDownloader\bin\Debug\TByte\User1\Videos\General\Ed Sheeran - Perfect Duet (with Beyoncé) [Official Audio].mp4"
It's a very stange problem and i have tried many alternatives but i believe it's to do with the symbols in the path as all the other YouTube videos without symbols work.
Is there a way round this? Could anyone help?