public async Task <MetadataResult <MusicVideo> > GetMetadata(MusicVideoInfo info, CancellationToken cancellationToken) { var result = new MetadataResult <MusicVideo>(); var id = YoutubeMetadataProvider.Current.GetYTID(info.Name); _logger.LogInformation(id); if (!string.IsNullOrWhiteSpace(id)) { await YoutubeMetadataProvider.Current.EnsureInfo(id, cancellationToken).ConfigureAwait(false); var path = YoutubeMetadataProvider.GetVideoInfoPath(_config.ApplicationPaths, id); var video = _json.DeserializeFromFile <Google.Apis.YouTube.v3.Data.Video>(path); if (video != null) { result.Item = new MusicVideo(); result.HasMetadata = true; result.Item.OriginalTitle = info.Name; YoutubeMetadataProvider.Current.ProcessResult(result.Item, video); result.AddPerson(YoutubeMetadataProvider.CreatePerson(video.Snippet.ChannelTitle, video.Snippet.ChannelId)); } } else { _logger.LogInformation("Youtube ID not found in filename of title: " + info.Name); } return(result); }
public Task <MetadataResult <Movie> > GetMetadata(ItemInfo info, IDirectoryService directoryService, CancellationToken cancellationToken) { var result = new MetadataResult <Movie>(); if (Plugin.Instance.Configuration.DisableLocalMetadata) { _logger.LogInformation("Local Metadata Disabled"); result.HasMetadata = false; return(Task.FromResult(result)); } try { var item = new Movie(); var infoJson = GetInfoJson(info.Path); result.HasMetadata = true; result.Item = item; var jsonObj = ReadJsonData(result, infoJson.FullName, cancellationToken); result.Item.Name = jsonObj.title; result.Item.Overview = jsonObj.description; var date = DateTime.ParseExact(jsonObj.upload_date, "yyyyMMdd", null); result.Item.ProductionYear = date.Year; result.Item.PremiereDate = date; result.AddPerson(YoutubeMetadataProvider.CreatePerson(jsonObj.uploader, jsonObj.channel_id)); return(Task.FromResult(result)); } catch (FileNotFoundException) { _logger.LogInformation("Could not find {0}", info.Path); result.HasMetadata = false; return(Task.FromResult(result)); } }