mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Solving bug with tracks
This commit is contained in:
parent
538bc06597
commit
b0eab43d52
@ -87,25 +87,25 @@ namespace Kyoo.Models
|
||||
}
|
||||
}
|
||||
|
||||
public string Link
|
||||
public string Slug
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Type != StreamType.Subtitle)
|
||||
return null;
|
||||
string link = "/subtitle/" + Episode.Slug + "." + Language;
|
||||
string slug = $"/subtitle/{Episode.Slug}.{Language ?? ID.ToString()}";
|
||||
if (IsForced)
|
||||
link += "-forced";
|
||||
slug += "-forced";
|
||||
switch (Codec)
|
||||
{
|
||||
case "ass":
|
||||
link += ".ass";
|
||||
slug += ".ass";
|
||||
break;
|
||||
case "subrip":
|
||||
link += ".srt";
|
||||
slug += ".srt";
|
||||
break;
|
||||
}
|
||||
return link;
|
||||
return slug;
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,11 +127,13 @@ namespace Kyoo.Models
|
||||
}
|
||||
|
||||
//Converting mkv track language to c# system language tag.
|
||||
public static string GetLanguage(string mkvLanguage)
|
||||
private static string GetLanguage(string mkvLanguage)
|
||||
{
|
||||
if (mkvLanguage == "fre")
|
||||
return "fra";
|
||||
return mkvLanguage;
|
||||
return mkvLanguage switch
|
||||
{
|
||||
"fre" => "fra",
|
||||
_ => mkvLanguage
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Kyoo.Models.Watch;
|
||||
|
||||
namespace Kyoo.Models
|
||||
{
|
||||
@ -14,7 +15,7 @@ namespace Kyoo.Models
|
||||
public int SeasonNumber;
|
||||
public int EpisodeNumber;
|
||||
public string Title;
|
||||
public string Link;
|
||||
public string Slug;
|
||||
public DateTime? ReleaseDate;
|
||||
[JsonIgnore] public string Path;
|
||||
public Episode PreviousEpisode;
|
||||
@ -47,7 +48,7 @@ namespace Kyoo.Models
|
||||
Path = path;
|
||||
|
||||
Container = Path.Substring(Path.LastIndexOf('.') + 1);
|
||||
Link = Episode.GetSlug(ShowSlug, seasonNumber, episodeNumber);
|
||||
Slug = Episode.GetSlug(ShowSlug, seasonNumber, episodeNumber);
|
||||
}
|
||||
|
||||
public WatchItem(int episodeID,
|
||||
@ -59,11 +60,13 @@ namespace Kyoo.Models
|
||||
DateTime? releaseDate,
|
||||
string path,
|
||||
IEnumerable<Track> audios,
|
||||
IEnumerable<Track> subtitles)
|
||||
IEnumerable<Track> subtitles,
|
||||
Track video)
|
||||
: this(episodeID, showTitle, showSlug, seasonNumber, episodeNumber, title, releaseDate, path)
|
||||
{
|
||||
Audios = audios;
|
||||
Subtitles = subtitles;
|
||||
Video = video;
|
||||
}
|
||||
|
||||
public WatchItem(Episode episode)
|
||||
@ -74,7 +77,10 @@ namespace Kyoo.Models
|
||||
episode.EpisodeNumber,
|
||||
episode.Title,
|
||||
episode.ReleaseDate,
|
||||
episode.Path)
|
||||
episode.Path,
|
||||
episode.Tracks.Where(x => x.Type == StreamType.Audio),
|
||||
episode.Tracks.Where(x => x.Type == StreamType.Subtitle),
|
||||
episode.Tracks.FirstOrDefault(x => x.Type == StreamType.Video))
|
||||
{
|
||||
if (EpisodeNumber > 1)
|
||||
PreviousEpisode = episode.Season.Episodes.FirstOrDefault(x => x.EpisodeNumber == EpisodeNumber - 1);
|
||||
|
@ -70,6 +70,9 @@ namespace Kyoo.Controllers
|
||||
if (obj.ExternalIDs != null)
|
||||
foreach (MetadataID entry in obj.ExternalIDs)
|
||||
_database.Entry(entry).State = EntityState.Added;
|
||||
if (obj.Tracks != null)
|
||||
foreach (Track entry in obj.Tracks)
|
||||
_database.Entry(entry).State = EntityState.Added;
|
||||
await _database.SaveChangesAsync();
|
||||
return obj.ID;
|
||||
}
|
||||
|
@ -52,7 +52,6 @@ namespace Kyoo.Controllers
|
||||
if (obj.EpisodeID <= 0)
|
||||
throw new InvalidOperationException($"Can't store a track not related to any episode (episodeID: {obj.EpisodeID}).");
|
||||
|
||||
obj.Episode = null;
|
||||
await _database.Tracks.AddAsync(obj);
|
||||
await _database.SaveChangesAsync();
|
||||
return obj.ID;
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit c34f62601a0561d0c35edec87f952d7ff6521e68
|
||||
Subproject commit fffb6690fc5db161767753d1fc554be04eb732d4
|
Loading…
x
Reference in New Issue
Block a user