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)
{
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;
}
@@ -337,6 +337,9 @@ namespace Opus.Fragments
await Task.Delay(500);
}
try
{
YoutubeClient client = new YoutubeClient();
Video video = await client.GetVideoAsync(youtubeID.Text);
if (!onlyArt)
@@ -349,6 +352,11 @@ namespace Opus.Fragments
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()
{