diff --git a/lua/autorun/wowozela.lua b/lua/autorun/wowozela.lua index f62d8db..f2ba9d1 100644 --- a/lua/autorun/wowozela.lua +++ b/lua/autorun/wowozela.lua @@ -152,11 +152,27 @@ if CLIENT then }) end + local patterns = { + ["drive.google.com/file/d/([%d%w]+)/view"] = "https://drive.google.com/u/0/uc?id=%s&export=download", + } + function wowozela.ProcessURL(url) + for pattern, replace in pairs(patterns) do + local match = string.match(url, pattern) + if match then + return string.format(replace, match) + end + end + + return url + end function wowozela.PlayURL(name, settings, callback, failurecallback) + if #name == 0 then return failurecallback and failurecallback("Empty URL?") end if not wowozela.URLWhitelist(name) then return failurecallback and failurecallback("Not a whitelisted URL.") end + + name = wowozela.ProcessURL(name) GetURLSound(name, function(sndPath) sound.PlayFile(sndPath, settings, callback) end, failurecallback or function() end) @@ -891,6 +907,9 @@ simple [[onedrive.live.com/redir]] --- https://docs.google.com/uc?export=download&confirm=UYyi&id=0BxUpZqVaDxVPeENDM1RtZDRvaTA simple [[docs.google.com/uc]] +simple [[drive.google.com/file/d/]] +simple [[drive.google.com/u/0/uc]] + --[=[ -- Imgur --- Examples: diff --git a/lua/weapons/wowozela.lua b/lua/weapons/wowozela.lua index 0341080..3ab54c5 100644 --- a/lua/weapons/wowozela.lua +++ b/lua/weapons/wowozela.lua @@ -1034,12 +1034,11 @@ if CLIENT then end) end - local function soundError(reason) LocalPlayer():ChatPrint(("Unable to load sound: %s"):format(reason)) end Menu:AddOption("custom...", function() - Derma_StringRequest("Sound (Mp3/Ogg)", "Insert a web-hosted ogg or mp3.\n(GitHub, Vocaroo, Dropbox, Puush, Google Drive or similar sites)", "", function(text) + Derma_StringRequest("Sound (Mp3/Ogg)", "Insert a web-hosted ogg or mp3.\n(GitHub, Vocaroo, Puush, Google Drive or similar sites)", "", function(text) if text:sub(1, 4) ~= "http" then return end if text:sub(1, 19) == "https://github.com/" and text:sub(-9) ~= "?raw=true" then