diff --git a/workshop/gamemodes/cinema_modded/gamemode/modules/theater/services/sh_image.lua b/workshop/gamemodes/cinema_modded/gamemode/modules/theater/services/sh_image.lua deleted file mode 100644 index f3ecf38..0000000 --- a/workshop/gamemodes/cinema_modded/gamemode/modules/theater/services/sh_image.lua +++ /dev/null @@ -1,67 +0,0 @@ -local SERVICE = {} - -SERVICE.Name = "Image" -SERVICE.IsTimed = false - -SERVICE.IsCacheable = false -SERVICE.Dependency = DEPENDENCY_NONE - -local validExtensions = { - ["jpg"] = true, - ["png"] = true, - ["bmp"] = true, - ["jpeg"] = true, - ["gif"] = true, -} - -function SERVICE:Match( url ) - return validExtensions[ string.GetExtensionFromFilename( url.path ) ] -end - -if (CLIENT) then - function SERVICE:LoadProvider( Video, panel ) - panel:OpenURL(Video:Data()) - end -end - -if (SERVER) then - CreateConVar("cinema_service_imageduration", "0", {FCVAR_ARCHIVE, FCVAR_NEVER_AS_STRING}, "0 = Infinite, 60sec Max", 0, 60 ) -end - -function SERVICE:GetURLInfo( url ) - - if url and url.encoded then - return { Data = url.encoded } - end - - return false - -end - -function SERVICE:GetVideoInfo( data, onSuccess, onFailure ) - - local info = {} - info.title = ("Image: %s"):format(data) - - local duration = GetConVar("cinema_service_imageduration"):GetInt() - if duration > 0 then - info.type = "image_timed" - info.duration = duration - end - - if onSuccess then - pcall(onSuccess, info) - end - -end - -theater.RegisterService( "image", SERVICE ) - -theater.RegisterService( "image_timed", { - Name = SERVICE.Name, - IsTimed = true, - IsCacheable = false, - Dependency = SERVICE.Dependency, - Hidden = true, - LoadProvider = CLIENT and SERVICE.LoadProvider or function() end -} ) \ No newline at end of file diff --git a/workshop/gamemodes/cinema_modded/gamemode/modules/theater/services/sh_hls.lua b/workshop/gamemodes/cinema_modded/gamemode/modules/theater/services/sh_url_hls.lua similarity index 94% rename from workshop/gamemodes/cinema_modded/gamemode/modules/theater/services/sh_hls.lua rename to workshop/gamemodes/cinema_modded/gamemode/modules/theater/services/sh_url_hls.lua index 11b5d82..3604e09 100644 --- a/workshop/gamemodes/cinema_modded/gamemode/modules/theater/services/sh_hls.lua +++ b/workshop/gamemodes/cinema_modded/gamemode/modules/theater/services/sh_url_hls.lua @@ -1,6 +1,6 @@ local SERVICE = {} -SERVICE.Name = "HLS Video" +SERVICE.Name = "URL (HLS Video)" SERVICE.IsTimed = true SERVICE.Dependency = DEPENDENCY_COMPLETE @@ -137,7 +137,7 @@ function SERVICE:GetVideoInfo( data, onSuccess, onFailure ) info.title = ("HLS: %s"):format(data:Data()) if metadata.live then - info.type = "hls_live" + info.type = "url_hlslive" info.duration = 0 else info.duration = math.Round(tonumber(metadata.duration)) @@ -150,9 +150,9 @@ function SERVICE:GetVideoInfo( data, onSuccess, onFailure ) end -theater.RegisterService( "hls", SERVICE ) -theater.RegisterService( "hls_live", { - Name = "HLS Live", +theater.RegisterService( "url_hls", SERVICE ) +theater.RegisterService( "url_hlslive", { + Name = "URL (HLS Live)", IsTimed = false, Dependency = DEPENDENCY_COMPLETE, Hidden = true, diff --git a/workshop/gamemodes/cinema_modded/gamemode/modules/theater/services/sh_url_image.lua b/workshop/gamemodes/cinema_modded/gamemode/modules/theater/services/sh_url_image.lua new file mode 100644 index 0000000..bf1b1d8 --- /dev/null +++ b/workshop/gamemodes/cinema_modded/gamemode/modules/theater/services/sh_url_image.lua @@ -0,0 +1,29 @@ +local SERVICE = {} + +SERVICE.Name = "URL (Image)" +SERVICE.IsTimed = false +SERVICE.Hidden = true + +SERVICE.IsCacheable = false +SERVICE.Dependency = DEPENDENCY_NONE + + +if (CLIENT) then + function SERVICE:LoadProvider( Video, panel ) + panel:OpenURL(Video:Data()) + end +end + +if (SERVER) then + CreateConVar("cinema_service_imageduration", "0", {FCVAR_ARCHIVE, FCVAR_NEVER_AS_STRING}, "0 = Infinite, 60sec Max", 0, 60 ) +end + +theater.RegisterService( "image", SERVICE ) +theater.RegisterService( "image_timed", { + Name = SERVICE.Name, + IsTimed = true, + IsCacheable = false, + Dependency = SERVICE.Dependency, + Hidden = true, + LoadProvider = CLIENT and SERVICE.LoadProvider or function() end +} ) \ No newline at end of file diff --git a/workshop/gamemodes/cinema_modded/gamemode/modules/theater/services/sh_file.lua b/workshop/gamemodes/cinema_modded/gamemode/modules/theater/services/sh_url_main.lua similarity index 71% rename from workshop/gamemodes/cinema_modded/gamemode/modules/theater/services/sh_file.lua rename to workshop/gamemodes/cinema_modded/gamemode/modules/theater/services/sh_url_main.lua index fe543e4..3762779 100644 --- a/workshop/gamemodes/cinema_modded/gamemode/modules/theater/services/sh_file.lua +++ b/workshop/gamemodes/cinema_modded/gamemode/modules/theater/services/sh_url_main.lua @@ -1,40 +1,50 @@ local SERVICE = {} -SERVICE.Name = "File" +SERVICE.Name = "URL" SERVICE.IsTimed = true +SERVICE.Hidden = true SERVICE.Dependency = DEPENDENCY_COMPLETE SERVICE.ExtentedVideoInfo = true --- Which endings are allowed to go through --- the match (regardless of whether CEF Codec Fix is present or not) -local validExtensions = { - - -- Video - ["mp4"] = true, - ["webm"] = true, +-- Don't use the domains of the other Services. +local excludedDomains = { + GetConVar("cinema_url_search"):GetString(), + "youtu.?be[.com]?", + "bilibili.com", + "b23.tv", + "dailymotion.com", + "archive.org", + "ok.ru", + "rutube.ru", + "rumble.com", + "sibnet.ru", + "vimeo.com", + "vk.com", + "twitch.tv" +} - -- Audio - ["mp3"] = true, - ["m4a"] = true, - ["wav"] = true, - ["ogg"] = true, +local validImageExtensions = { + ["jpg"] = true, + ["png"] = true, + ["bmp"] = true, + ["jpeg"] = true, + ["gif"] = true, } --- Which extensions are allowed if CEF Codec Fix is not present. -local limitedExtensions = { +function SERVICE:Match( url ) + local allowed = false - -- Video - ["webm"] = true, + for _, domain in pairs( excludedDomains ) do + allowed = false - -- Audio - ["mp3"] = true, - ["wav"] = true, - ["ogg"] = true, -} + if url.host and url.encoded:find(domain) then + allowed = true + break + end + end -function SERVICE:Match( url ) - return validExtensions[ string.GetExtensionFromFilename( url.path ) ] or GetConVar( "cinema_force_extension_bypass" ):GetBool() + return not allowed end if (CLIENT) then @@ -57,28 +67,28 @@ if (CLIENT) then
- + - + - + ]] @@ -151,7 +161,10 @@ end function SERVICE:GetURLInfo( url ) if url and url.encoded then - return { Data = url.encoded } + local info = {} + + info.Data = url.encoded + return info end return false @@ -159,6 +172,26 @@ end function SERVICE:GetVideoInfo( data, onSuccess, onFailure ) + -- Image Service + if validImageExtensions[ string.GetExtensionFromFilename( data:Data() ) ] then + local info = {} + info.title = ("Image: %s"):format(data:Data()) + + local duration = GetConVar("cinema_service_imageduration"):GetInt() + if duration > 0 then + info.type = "image_timed" + info.duration = duration + else + info.type = "image" + end + + if onSuccess then + pcall(onSuccess, info) + end + + return + end + theater.FetchVideoMedata( data:GetOwner(), data, function(metadata) if metadata.err then @@ -166,13 +199,9 @@ function SERVICE:GetVideoInfo( data, onSuccess, onFailure ) end local info = {} - info.title = ("File: %s"):format(data:Data()) + info.title = ("URL: %s"):format(data:Data()) info.duration = math.Round(tonumber(metadata.duration)) - if limitedExtensions[ string.GetExtensionFromFilename( data:Data() ) ] then - info.type = "file_limited" - end - if onSuccess then pcall(onSuccess, info) end @@ -180,13 +209,4 @@ function SERVICE:GetVideoInfo( data, onSuccess, onFailure ) end -theater.RegisterService( "file", SERVICE ) - --- Responsible that at least audio and WEBM videos without CEF codec work fix -theater.RegisterService( "file_limited", { - Name = "File (Limited)", - IsTimed = true, - Dependency = DEPENDENCY_PARTIAL, - Hidden = true, - LoadProvider = CLIENT and SERVICE.LoadProvider or function() end -} ) \ No newline at end of file +theater.RegisterService( "url", SERVICE ) \ No newline at end of file