diff --git a/Shoko.Server/Plex/TVShow/SVR_Episode.cs b/Shoko.Server/Plex/TVShow/SVR_Episode.cs
index 0069b79c1..3726c1833 100644
--- a/Shoko.Server/Plex/TVShow/SVR_Episode.cs
+++ b/Shoko.Server/Plex/TVShow/SVR_Episode.cs
@@ -1,4 +1,4 @@
-using System.IO;
+using System.IO;
using Shoko.Models.Plex.TVShow;
using Shoko.Server.Models;
using Shoko.Server.Repositories;
@@ -15,7 +15,7 @@ public SVR_Episode(PlexHelper helper)
}
public SVR_AnimeEpisode AnimeEpisode =>
- RepoFactory.AnimeEpisode.GetByFilename(Path.GetFileName(Media[0].Part[0].File));
+ RepoFactory.AnimeEpisode.GetByFilename(Path.GetFileName(Media[0].Part[0].File), Media[0].Part[0].Size);
public void Unscrobble()
{
diff --git a/Shoko.Server/Repositories/Cached/AnimeEpisodeRepository.cs b/Shoko.Server/Repositories/Cached/AnimeEpisodeRepository.cs
index aa2ba949f..f4dcdb250 100644
--- a/Shoko.Server/Repositories/Cached/AnimeEpisodeRepository.cs
+++ b/Shoko.Server/Repositories/Cached/AnimeEpisodeRepository.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -56,8 +56,9 @@ public SVR_AnimeEpisode GetByAniDBEpisodeID(int epid)
/// Get the AnimeEpisode
///
/// The filename of the anime to search for.
+ /// The size of the file in bytes
/// the AnimeEpisode given the file information
- public SVR_AnimeEpisode GetByFilename(string name)
+ public SVR_AnimeEpisode GetByFilename(string name, long size = -1)
{
if (string.IsNullOrEmpty(name))
{
@@ -68,6 +69,7 @@ public SVR_AnimeEpisode GetByFilename(string name)
.Where(v => name.Equals(v?.FilePath?.Split(Path.DirectorySeparatorChar).LastOrDefault(),
StringComparison.InvariantCultureIgnoreCase))
.Select(a => RepoFactory.VideoLocal.GetByID(a.VideoLocalID)).Where(a => a != null)
+ .Where(a => size == -1 || a.FileSize == size)
.SelectMany(a => GetByHash(a.Hash)).ToArray();
var ep = eps.FirstOrDefault(a => a.AniDB_Episode.EpisodeType == (int)EpisodeType.Episode);
return ep ?? eps.FirstOrDefault();