mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-23 15:30:34 -04:00
Fix auto refresh date calculation
This commit is contained in:
parent
c7521b4af0
commit
5364359788
@ -27,16 +27,13 @@ public interface IRefreshable
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime? NextMetadataRefresh { get; set; }
|
public DateTime? NextMetadataRefresh { get; set; }
|
||||||
|
|
||||||
public static DateTime ComputeNextRefreshDate(DateOnly? airDate)
|
public static DateTime ComputeNextRefreshDate(DateOnly airDate)
|
||||||
{
|
{
|
||||||
if (airDate is null)
|
int days = DateOnly.FromDateTime(DateTime.UtcNow).DayNumber - airDate.DayNumber;
|
||||||
return DateTime.UtcNow.AddDays(1);
|
|
||||||
|
|
||||||
int days = airDate.Value.DayNumber - DateOnly.FromDateTime(DateTime.UtcNow).DayNumber;
|
|
||||||
return days switch
|
return days switch
|
||||||
{
|
{
|
||||||
<= 7 => DateTime.UtcNow.AddDays(1),
|
<= 4 => DateTime.UtcNow.AddDays(1),
|
||||||
<= 21 => DateTime.UtcNow.AddDays(5),
|
<= 21 => DateTime.UtcNow.AddDays(14),
|
||||||
_ => DateTime.UtcNow.AddMonths(2)
|
_ => DateTime.UtcNow.AddMonths(2)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,9 @@ public class EpisodeRepository(
|
|||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
resource.NextMetadataRefresh ??= IRefreshable.ComputeNextRefreshDate(resource.ReleaseDate);
|
resource.NextMetadataRefresh ??= IRefreshable.ComputeNextRefreshDate(
|
||||||
|
resource.ReleaseDate ?? DateOnly.FromDateTime(resource.AddedDate)
|
||||||
|
);
|
||||||
await thumbnails.DownloadImages(resource);
|
await thumbnails.DownloadImages(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -74,7 +75,9 @@ public class MovieRepository(
|
|||||||
resource.StudioId = (await studios.CreateIfNotExists(resource.Studio)).Id;
|
resource.StudioId = (await studios.CreateIfNotExists(resource.Studio)).Id;
|
||||||
resource.Studio = null;
|
resource.Studio = null;
|
||||||
}
|
}
|
||||||
resource.NextMetadataRefresh ??= IRefreshable.ComputeNextRefreshDate(resource.AirDate);
|
resource.NextMetadataRefresh ??= IRefreshable.ComputeNextRefreshDate(
|
||||||
|
resource.AirDate ?? DateOnly.FromDateTime(resource.AddedDate)
|
||||||
|
);
|
||||||
await thumbnails.DownloadImages(resource);
|
await thumbnails.DownloadImages(resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,9 @@ public class SeasonRepository(
|
|||||||
throw new ValidationException("Missing show id");
|
throw new ValidationException("Missing show id");
|
||||||
// This is storred in db so it needs to be set before every create/edit (and before events)
|
// This is storred in db so it needs to be set before every create/edit (and before events)
|
||||||
resource.ShowSlug = (await shows.Get(resource.ShowId)).Slug;
|
resource.ShowSlug = (await shows.Get(resource.ShowId)).Slug;
|
||||||
resource.NextMetadataRefresh ??= IRefreshable.ComputeNextRefreshDate(resource.StartDate);
|
resource.NextMetadataRefresh ??= IRefreshable.ComputeNextRefreshDate(
|
||||||
|
resource.StartDate ?? DateOnly.FromDateTime(resource.AddedDate)
|
||||||
|
);
|
||||||
await thumbnails.DownloadImages(resource);
|
await thumbnails.DownloadImages(resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -74,7 +75,9 @@ public class ShowRepository(
|
|||||||
resource.StudioId = (await studios.CreateIfNotExists(resource.Studio)).Id;
|
resource.StudioId = (await studios.CreateIfNotExists(resource.Studio)).Id;
|
||||||
resource.Studio = null;
|
resource.Studio = null;
|
||||||
}
|
}
|
||||||
resource.NextMetadataRefresh ??= IRefreshable.ComputeNextRefreshDate(resource.StartAir);
|
resource.NextMetadataRefresh ??= IRefreshable.ComputeNextRefreshDate(
|
||||||
|
resource.StartAir ?? DateOnly.FromDateTime(resource.AddedDate)
|
||||||
|
);
|
||||||
await thumbnails.DownloadImages(resource);
|
await thumbnails.DownloadImages(resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user