Point a media player at a folder of video files and you get a list of file names. Holiday in Lisbon 2019.mp4, My Show S02E05.mkv, Garden Documentary (2014).mkv,…
Point a media player at a folder of video files and you get a list of file names. Holiday in Lisbon 2019.mp4, My Show S02E05.mkv, Garden Documentary (2014).mkv, IMG_2041.mov. What a person wants is a wall of posters, with Films, Series and their seasons, and a description when they open one. Yonto Player does that for the video files you keep on a NAS, a USB drive or the device itself.
This post covers the parser, the grouping, the order of artwork, and a lookup built so that no path or file name leaves the device. The parser: decline to guess when the name is unclear The parser is written from scratch in Kotlin. The idea is simple: split the name into tokens and find the first one that cannot be part of a title. That is where the title ends.
A marker that ends a title is a season or episode (S02E05, 2nd Season, 第3集), a date, a year, or a descriptive tag such as an edition. Here is the shape of it, as a simplified sketch with generic names, not the real file: fun parse(tokens: List): Parsed { var titleEnd: Int? = null var year: Int? = null var season: Int? = null var episode: Int?
= null fun cut(at: Int) { if (titleEnd == null) titleEnd = at } val title = tokens.take(titleEnd ?: tokens.size).joinToString(" ") return Parsed(title, year, season, episode) } The real code has far more cases; the telling ones are where it declines to read a marker. A year is 1900 to 2030, and never the first word. 1917 and 2012 are titles. Mars 2049 is a title with no year, and Mars 2049 (2017) finds 2017. Of a run of years, the last one is the year.
A bare number is an episode only where the structure says it is a series. Garden Notes - 3.mkv is a film. In a name with a hyphen and a number, the number alone is not enough; a file inside a season folder is. Words that are also words stay words. Space Saga Episode 4 keeps its number in the title. All three come from one decision: where a name gives no clear signal, a wrong guess is worse than none.
This is a source-linked briefing. Read the original report from Dev Community .