Adding youtube id validation on the edit metadata downloader.

This commit is contained in:
Anonymus Raccoon
2019-06-29 23:51:38 +02:00
parent 01e25d3469
commit cae1885999

View File

@@ -320,9 +320,9 @@ namespace Opus.Fragments
async void DownloadMetaDataFromYT(bool onlyArt) async void DownloadMetaDataFromYT(bool onlyArt)
{ {
if (song.YoutubeID == "") if (song.YoutubeID == "" && YoutubeClient.ValidateVideoId(song.YoutubeID))
{ {
Toast.MakeText(this, Resource.String.metdata_error_noid, ToastLength.Short).Show(); Toast.MakeText(this, Resource.String.metdata_error_noid, ToastLength.Long).Show();
return; return;
} }
@@ -337,17 +337,25 @@ namespace Opus.Fragments
await Task.Delay(500); await Task.Delay(500);
} }
YoutubeClient client = new YoutubeClient();
Video video = await client.GetVideoAsync(youtubeID.Text);
if (!onlyArt)
{
title.Text = video.Title;
artist.Text = video.Author;
album.Text = video.Title + " - " + video.Author;
}
ytThumbUri = await YoutubeManager.GetBestThumb(video.Thumbnails); try
Picasso.With(this).Load(ytThumbUri).Placeholder(Resource.Drawable.noAlbum).Transform(new RemoveBlackBorder(true)).MemoryPolicy(MemoryPolicy.NoCache, MemoryPolicy.NoStore).Into(albumArt); {
YoutubeClient client = new YoutubeClient();
Video video = await client.GetVideoAsync(youtubeID.Text);
if (!onlyArt)
{
title.Text = video.Title;
artist.Text = video.Author;
album.Text = video.Title + " - " + video.Author;
}
ytThumbUri = await YoutubeManager.GetBestThumb(video.Thumbnails);
Picasso.With(this).Load(ytThumbUri).Placeholder(Resource.Drawable.noAlbum).Transform(new RemoveBlackBorder(true)).MemoryPolicy(MemoryPolicy.NoCache, MemoryPolicy.NoStore).Into(albumArt);
}
catch(YoutubeExplode.Exceptions.VideoUnavailableException)
{
Toast.MakeText(this, Resource.String.metdata_error_noid, ToastLength.Long).Show();
}
} }
void UndoChange() void UndoChange()