[vlc-commits] [Git][videolan/vlc][master] vlcsub: improve movie info matching
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Thu May 12 13:44:09 UTC 2022
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
4417cfc6 by Marcin Jakubowski at 2022-05-12T13:27:00+00:00
vlcsub: improve movie info matching
improves movie info (show name, season and episode number) matching by
trying meta data as well as the cleaned up filename and trying out
additional patterns
- - - - -
1 changed file:
- share/lua/extensions/VLSub.lua
Changes:
=====================================
share/lua/extensions/VLSub.lua
=====================================
@@ -1255,6 +1255,12 @@ openSub = {
end,
getMovieInfo = function()
-- Clean video file name and check for season/episode pattern in title
+ local movie_info_patterns = {
+ "(.+)[sS](%d+)[eE](%d+).*",
+ "(.+)(%d+)[xX](%d%d).*",
+ "(.+)[%s%p]*[Ss]eason[%s%p]*(%d+)[%s%p]*[Ee]pisode[%s%p]*(%d+).*",
+ "(.+)[%s%p]*[Ss]eries[%s%p]*(%d+)[%s%p]*[Ee]pisode[%s%p]*(%d+).*"
+ }
if not openSub.file.name then
openSub.movie.title = ""
openSub.movie.seasonNumber = ""
@@ -1262,14 +1268,21 @@ openSub = {
return false
end
- local showName, seasonNumber, episodeNumber = string.match(
- openSub.file.cleanName or "",
- "(.+)[sS](%d%d)[eE](%d%d).*")
-
- if not showName then
- showName, seasonNumber, episodeNumber = string.match(
- openSub.file.cleanName or "",
- "(.+)(%d)[xX](%d%d).*")
+ local item = openSub.getInputItem()
+ -- try cleaned file name as well as meta information (e.g. from youtube)
+ local names = { openSub.file.cleanName, item:metas()['title'] }
+
+ local showName, seasonNumber, episodeNumber
+ for _,name in ipairs(names) do
+ if name then
+ -- try matching the pattern, stop if a match is found
+ for _,pattern in ipairs(movie_info_patterns) do
+ showName, seasonNumber, episodeNumber = string.match(name, pattern)
+ if showName then
+ break
+ end
+ end
+ end
end
if showName then
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/4417cfc668f1589bb4091225ff591e25adff3c19
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/4417cfc668f1589bb4091225ff591e25adff3c19
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list