diff --git a/lua/cfc_http_restrictions/shared/filetypes.lua b/lua/cfc_http_restrictions/shared/filetypes.lua index 03af135..02466ef 100644 --- a/lua/cfc_http_restrictions/shared/filetypes.lua +++ b/lua/cfc_http_restrictions/shared/filetypes.lua @@ -18,11 +18,11 @@ function CFCHTTP.getFileType( data ) end ---@param url string ----@param callback fun( urls: string[], err: string|nil) +---@param callback fun( urls: string[], err: string|nil, code ) function CFCHTTP.GetFileDataURLS( url, callback ) http.Fetch( url, function( body, _, _, code ) if code < 200 or code > 299 then - callback( {}, "HTTP request returned status code " .. code ) + callback( {}, "HTTP request returned status code " .. code, code ) return end diff --git a/lua/cfc_http_restrictions/wraps/playURL.lua b/lua/cfc_http_restrictions/wraps/playURL.lua index 85d33d1..f79a23e 100644 --- a/lua/cfc_http_restrictions/wraps/playURL.lua +++ b/lua/cfc_http_restrictions/wraps/playURL.lua @@ -31,13 +31,21 @@ local function wrapPlayURL() return end - CFCHTTP.GetFileDataURLS( url, function( uris, err ) + CFCHTTP.GetFileDataURLS( url, function( uris, err, code ) if err ~= nil then logData.urls[1].status = "blocked" logData.urls[1].reason = err CFCHTTP.LogRequest( logData ) - if callback then callback( nil, CFCHTTP.BASS_ERROR_BLOCKED_CONTENT, "BASS_ERROR_BLOCKED_CONTENT" ) end + if callback then + if code == 401 or code == 403 then + callback( nil, 49, "BASS_ERROR_DENIED" ) + elseif code == 404 then + callback( nil, 2, "BASS_ERROR_FILEOPEN" ) + else + callback( nil, CFCHTTP.BASS_ERROR_BLOCKED_CONTENT, "BASS_ERROR_BLOCKED_CONTENT" ) + end + end return end if #uris == 0 then