Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix movies sort by start/end air date on items routes #332

Merged
merged 4 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions INSTALLING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Kyoo will default to use your primary card (located at `/dev/dri/renderD128`). I
can use the `GOTRANSCODER_VAAPI_RENDERER` env-var to specify `/dev/dri/renderD129` or another one.

Then you can simply run kyoo using `docker compose --profile vaapi up -d` (notice the `--profile vaapi` added)
You can also add `COMPOSE_PROFILES=vaapi` to your `.env` instead of adding the `--profile` flag.

## Nvidia

Expand All @@ -93,6 +94,7 @@ To test if everything works, you can run `sudo docker run --rm --gpus all ubuntu
you might need to add `--runtime nvidia` like so: `sudo docker run --rm --runtime=nvidia --gpus all ubuntu nvidia-smi`

After that, you can now use `docker compose --profile nvidia up -d` to start kyoo with nvidia hardware acceleration (notice the `--profile nvidia` added).
You can also add `COMPOSE_PROFILES=nvidia` to your `.env` instead of adding the `--profile` flag.

Note that most nvidia cards have an artificial limit on the number of encodes. You can confirm your card limit [here](https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new).
This limit can also be removed by applying an [unofficial patch](https://github.com/keylase/nvidia-patch) to you driver.
9 changes: 9 additions & 0 deletions back/src/Kyoo.Abstractions/Models/Resources/Movie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using EntityFrameworkCore.Projectables;
using Kyoo.Abstractions.Controllers;
Expand Down Expand Up @@ -118,6 +119,14 @@ public class Movie
/// <inheritdoc />
public Image? Logo { get; set; }

[SerializeIgnore]
[Column("air_date")]
public DateTime? StartAir => AirDate;

[SerializeIgnore]
[Column("air_date")]
public DateTime? EndAir => AirDate;

/// <summary>
/// A video of a few minutes that tease the content.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions front/packages/models/src/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const getTokenWJ = async (account?: Account | null): ReturnType<typeof ru
let token = account.token;

if (account.token.expire_at <= new Date(new Date().getTime() + 10 * 1000)) {
console.log("refreshing token for account", account.slug);
try {
token = await queryFn(
{
Expand Down
14 changes: 13 additions & 1 deletion scanner/providers/implementations/themoviedatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ async def get_absolute_number(self, show_id: str, season: int, episode_nbr: int)
)
+ episode_nbr
)
return next(
absolute = next(
(
# The + 1 is to go from 0based index to 1based absolute number
i + 1
Expand All @@ -664,6 +664,18 @@ async def get_absolute_number(self, show_id: str, season: int, episode_nbr: int)
),
None,
)
if absolute is not None:
return absolute
# assume we use tmdb weird absolute by default (for example, One Piece S21E800, the first
# episode of S21 si not reset to 0 but keep increasing so it can be 800
start = next(
(x["episode_number"] for x in absgrp if x["season_number"] == season), None
)
if start is None or start <= episode_nbr:
return None
# add back the continuous number (imagine the user has one piece S21e31
# but tmdb registered it as S21E831 since S21's first ep is 800
return await self.get_absolute_number(show_id, season, episode_nbr + start)

async def identify_collection(self, provider_id: str) -> Collection:
languages = self.get_languages()
Expand Down
8 changes: 5 additions & 3 deletions scanner/scanner/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
async def main():
import asyncio
import os
import logging
import sys
Expand Down Expand Up @@ -38,8 +39,9 @@ async def main():
) as client:
try:
scanner = Scanner(client, languages=languages.split(","), api_key=api_key)
await scanner.scan(path)
logging.info("Scan finished. Starting to monitor...")
await monitor(path, scanner)
await asyncio.gather(
monitor(path, scanner),
scanner.scan(path),
)
except ProviderError as e:
logging.error(e)
1 change: 1 addition & 0 deletions scanner/scanner/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ async def scan(self, path: str):
# We batch videos by 20 because too mutch at once kinda DDOS everything.
for group in batch(iter(videos), 20):
await asyncio.gather(*map(self.identify, group))
logging.info("Scan finished.")

async def get_registered_paths(self) -> List[str]:
paths = None
Expand Down
Loading