Skip to content

Commit

Permalink
Fixing bug where youtube remote images provider would try and look fo…
Browse files Browse the repository at this point in the history
…r item name which would be renamed to the title rather than the filename with the ID.
  • Loading branch information
ankenyr committed Sep 11, 2020
1 parent 800669a commit 5c64e4c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<RootNamespace>Jellyfin.Plugin.YoutubeMetadata</RootNamespace>
<AssemblyVersion>1.0.2.1</AssemblyVersion>
<FileVersion>1.0.2.1</FileVersion>
<Version>1.0.2.1</Version>
<AssemblyVersion>1.0.2.2</AssemblyVersion>
<FileVersion>1.0.2.2</FileVersion>
<Version>1.0.2.2</Version>
</PropertyGroup>
<ItemGroup>
<None Remove="Configuration\configPage.html" />
Expand All @@ -14,10 +14,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Google.Apis" Version="1.45.0" />
<PackageReference Include="Google.Apis.Auth" Version="1.45.0" />
<PackageReference Include="Google.Apis.Core" Version="1.45.0" />
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.45.0.1905" />
<PackageReference Include="Jellyfin.Controller" Version="10.*-*" />
<PackageReference Include="Google.Apis" Version="1.45.0" />
<PackageReference Include="Google.Apis.Auth" Version="1.45.0" />
<PackageReference Include="Google.Apis.Core" Version="1.45.0" />
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.45.0.1905" />
<PackageReference Include="Jellyfin.Controller" Version="10.*-*" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public YoutubeMetadataImageProvider(IServerConfigurationManager config, IHttpCli

/// <inheritdoc />
// After embedded and fanart
public int Order => 2;
public int Order => 1;

/// <inheritdoc />
public IEnumerable<ImageType> GetSupportedImages(BaseItem item)
Expand All @@ -49,7 +49,7 @@ public IEnumerable<ImageType> GetSupportedImages(BaseItem item)
/// <inheritdoc />
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, CancellationToken cancellationToken)
{
var id = YoutubeMetadataProvider.Current.GetYTID(item.Name);
var id = YoutubeMetadataProvider.Current.GetYTID(item.FileNameWithoutExtension);

if (!string.IsNullOrWhiteSpace(id))
{
Expand Down Expand Up @@ -84,6 +84,10 @@ public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, Cancell

return GetImages(tnurls);
}
else
{
_logger.LogInformation("Object is null!");
}
}

return new List<RemoteImageInfo>();
Expand Down
10 changes: 4 additions & 6 deletions Jellyfin.Plugin.YoutubeMetadata/Providers/YoutubeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,19 @@ private string GetPathByTitle(string title)
/// <summary>
/// Returns the Youtube ID from the file path. Matches last 11 character field inside square brackets.
/// </summary>
/// <param name="title"></param>
/// <param name="name"></param>
/// <returns></returns>
internal string GetYTID(string title)
internal string GetYTID(string name)
{
var filename = GetPathByTitle(title);
var match = Regex.Match(filename, YTID_RE);
var match = Regex.Match(name, YTID_RE);
return match.Value;

}

/// <inheritdoc />
public async Task<MetadataResult<Movie>> GetMetadata(MovieInfo info, CancellationToken cancellationToken)
{
var result = new MetadataResult<Movie>();
var id = GetYTID(info.Name);
var id = GetYTID(GetPathByTitle(info.Name));

_logger.LogInformation(id);

Expand Down

0 comments on commit 5c64e4c

Please sign in to comment.