stremio/node/media-node/internal/scanner/parser_test.go
Jos Vooges | STH eb8ae1e85a Fix Stremio playback, folder-aware scan, and remove STH branding.
Parse Plex-style Title (Year) and Show/Season folders; restore notWebReady with direct node stream URLs; hide unavailable titles by default.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-25 02:16:46 +02:00

81 lines
2 KiB
Go

package scanner
import "testing"
func TestParseMovie(t *testing.T) {
p := parseMovie("The.Matrix.1999.2160p.UHD.BluRay.REMUX.HEVC.TrueHD.Atmos")
if p == nil {
t.Fatal("expected parse result")
}
if p["title"] != "The Matrix" {
t.Fatalf("title=%v", p["title"])
}
if p["year"] != 1999 {
t.Fatalf("year=%v", p["year"])
}
}
func TestParseMovieParenFolder(t *testing.T) {
p := parseMovieFromPath(`/media/movies/Inception (2010)/Inception.mkv`)
if p == nil {
t.Fatal("expected parse result")
}
if p["title"] != "Inception" {
t.Fatalf("title=%v", p["title"])
}
if p["year"] != 2010 {
t.Fatalf("year=%v", p["year"])
}
}
func TestParseSeries(t *testing.T) {
p := parseSeries("Breaking.Bad.S03E04.1080p.BluRay")
if p == nil {
t.Fatal("expected parse result")
}
if p["title"] != "Breaking Bad" {
t.Fatalf("title=%v", p["title"])
}
if p["season"] != 3 || p["episode"] != 4 {
t.Fatalf("season/episode=%v/%v", p["season"], p["episode"])
}
}
func TestParseSeriesAlt(t *testing.T) {
p := parseSeries("Show.Name.1x02.720p")
if p == nil || p["season"] != 1 || p["episode"] != 2 {
t.Fatalf("unexpected: %#v", p)
}
}
func TestParseSeriesSeasonFolder(t *testing.T) {
p := parseSeriesFromPath(`/media/series/Breaking Bad/Season 01/Breaking.Bad.S01E01.mkv`)
if p == nil {
t.Fatal("expected parse result")
}
if p["title"] != "Breaking Bad" {
t.Fatalf("title=%v", p["title"])
}
if p["season"] != 1 || p["episode"] != 1 {
t.Fatalf("season/episode=%v/%v", p["season"], p["episode"])
}
}
func TestParseSeriesSeasonFolderEpisodeOnly(t *testing.T) {
p := parseSeriesFromPath(`/media/series/The Office/Season 2/E05 - Episode.mkv`)
if p == nil {
t.Fatal("expected parse result")
}
if p["title"] != "The Office" {
t.Fatalf("title=%v", p["title"])
}
if p["season"] != 2 || p["episode"] != 5 {
t.Fatalf("season/episode=%v/%v", p["season"], p["episode"])
}
}
func TestSkipSample(t *testing.T) {
if parseMovieFromPath(`/media/movies/Foo (2020)/Foo-sample.mkv`) != nil {
t.Fatal("sample should be skipped")
}
}