Skip to content

Commit

Permalink
Plex sync job: match file using parent folder + filename
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithmohan committed Sep 14, 2024
1 parent 010fd36 commit e13b48a
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Shoko.Server/Plex/TVShow/SVR_Episode.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using System.Linq;
using Shoko.Models.Plex.TVShow;
using Shoko.Server.Models;
Expand Down Expand Up @@ -27,13 +28,17 @@ public SVR_AnimeEpisode AnimeEpisode
"macos" => '/',
"darwin" => '/',
"android" => '/',

_ => Path.DirectorySeparatorChar,
};

var filename = Media[0].Part[0].File.Split(separator).LastOrDefault();

return filename is null ? null : RepoFactory.AnimeEpisode.GetByFilename(filename);

var filenameWithParent = Path.Join(Media[0].Part[0].File.Split(separator)[^2..]);

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

return file is null ? null : RepoFactory.AnimeEpisode.GetByHash(file.Hashes.ED2K).FirstOrDefault();

}
}
Expand Down

0 comments on commit e13b48a

Please sign in to comment.