Skip to content

Commit

Permalink
Fix cross-platform plex sync, get episode data using both parent fold…
Browse files Browse the repository at this point in the history
…er and filename (#1176)

* Fix cross-platform plex sync

* Plex sync job: use both parent folder and file name to get episode
  • Loading branch information
harshithmohan authored Sep 13, 2024
1 parent eafdce5 commit 34f870d
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions Shoko.Server/Plex/TVShow/SVR_Episode.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.IO;
using System;
using System.IO;
using System.Linq;
using Shoko.Models.Plex.TVShow;
using Shoko.Server.Models;
using Shoko.Server.Repositories;
Expand All @@ -14,8 +16,24 @@ public SVR_Episode(PlexHelper helper)
Helper = helper;
}

public SVR_AnimeEpisode AnimeEpisode =>
RepoFactory.AnimeEpisode.GetByFilename(Path.GetFileName(Media[0].Part[0].File));
public SVR_AnimeEpisode AnimeEpisode
{
get
{
var normalizedPath = Media[0].Part[0].File.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar);

var finalPath = Path.Combine(
Path.GetFileName(Path.GetDirectoryName(normalizedPath)) ?? string.Empty,
Path.GetFileName(normalizedPath)
);

var file = RepoFactory.VideoLocalPlace
.GetAll()
.FirstOrDefault(location => location.FullServerPath?.EndsWith(finalPath, StringComparison.OrdinalIgnoreCase) ?? false);

return string.IsNullOrEmpty(file?.Hashes.ED2K) ? null : RepoFactory.AnimeEpisode.GetByHash(file.Hashes.ED2K).FirstOrDefault();
}
}

public void Unscrobble()
{
Expand Down

0 comments on commit 34f870d

Please sign in to comment.