--[[ Adaptación del script de Dailymotion para soportar URLs de geo.dailymotion.com --]] -- Probe function optimizada function probe() return ( vlc.access == "http" or vlc.access == "https" ) and ( string.match( vlc.path, "^www%.dailymotion%.com/video/" ) or string.match( vlc.path, "^geo%.dailymotion%.com/player" ) ) end -- Parse function function parse() local video_id = nil -- Lógica para extraer ID según el tipo de URL if string.match( vlc.path, "geo%.dailymotion%.com" ) then -- Extrae el ID del parámetro 'video=' video_id = string.match( vlc.path, "video=([%a%d]+)" ) else -- Extrae el ID de la URL estándar video_id = string.match( vlc.path, "/video/([^/?#]+)" ) end if not video_id then vlc.msg.err("No se pudo encontrar el ID del video de Dailymotion") return { } end -- Obtenemos los metadatos usando el ID extraído -- Dailymotion suele permitir peticiones a su API de player con el ID local metadata_url = vlc.access.."://www.dailymotion.com/player/metadata/video/"..video_id local metadata = vlc.stream( metadata_url ) if not metadata then vlc.msg.err("No se pudo acceder a la API de metadatos") return { } end local line = metadata:readline() -- El JSON viene en una sola línea local path = nil local name = "Dailymotion Video " .. video_id local arturl, artist, description -- Extracción de la URL del stream (HLS o Progresivo) local streams = string.match( line, "\"qualities\":{(.-%])}" ) if streams then local prefres = vlc.var.inherit(nil, "preferred-resolution") local file = nil local live = nil for height, stream in string.gmatch( streams, "\"(%w+)\":%[(.-)%]" ) do -- Prioridad a archivos directos según resolución preferida if string.match( height, "^(%d+)$" ) and ( ( not file ) or prefres < 0 or tonumber( height ) <= prefres ) then local f = string.match( stream, '"type":"video\\/[^"]+","url":"([^"]+)"' ) if f then file = f end end -- Fallback a HLS (application/x-mpegURL) if not live then live = string.match( stream, '"type":"application\\/x%-mpegURL","url":"([^"]+)"' ) end end path = file or live if path then path = string.gsub( path, "\\/", "/") end end -- Intento de extraer metadatos adicionales del JSON si están disponibles artist = string.match( line, '"username":"([^"]+)"' ) local poster = string.match( line, '"poster_url":"([^"]+)"' ) if poster then arturl = string.gsub( poster, "\\/", "/") end if not path then vlc.msg.err("Error: No se pudo extraer la URL final del video") return { } end return { { path = path; name = name; description = description; arturl = arturl; artist = artist } } end