UserToDelete Posted August 21, 2015 Posted August 21, 2015 Bueno, tengo un problema con un JSON que transformé de una pagina web, cuya string era esta: "http:\/\/www.download.com\/%20" etc etc etc Bueno, la cosa es, que al poner un string.len(string), me dió error, como si la string no la reconociera adecuadamente, como se puede solucionar eso? De hecho el error que me dió el script precisamente fue en la linea 1, en donde tengo la string
Sasu Posted August 21, 2015 Posted August 21, 2015 · Hidden Hidden Que error tira? Expected string got nil?
UserToDelete Posted August 21, 2015 Author Posted August 21, 2015 No exactamente, es un error que jamas habia visto antes, aver si logro reproducirlo de nuevo.. Error(s), warning(s): lua: source_file.lua:1: invalid escape sequence near '\/' str = "http:\/\/youtubeinmp3.com\/download\/get\/?i=wOLDLDQ54a8caHsn4AVM0suO0eHh0z7Hwn%2FO8JPSYL4rzkK3C0f1bWODGZeLUS820jAQKsW3ZQeVaXVcGKrlgw%3D%3D" print(str)
Sasu Posted August 21, 2015 Posted August 21, 2015 · Hidden Hidden Las barras inversa se deben poner doble, es decir "\\", ya que estas tienen otras funciones
UserToDelete Posted August 21, 2015 Author Posted August 21, 2015 Entonces tengo un problema, ya que la web me returna eso, tengo alguna forma de hacerlo?
Sasu Posted August 21, 2015 Posted August 21, 2015 · Hidden Hidden Le pones doble corchete fuera de las comillas. str = [["http:\/\/youtubeinmp3.com\/download\/get\/?i=wOLDLDQ54a8caHsn4AVM0suO0eHh0z7Hwn%2FO8JPSYL4rzkK3C0f1bWODGZeLUS820jAQKsW3ZQeVaXVcGKrlgw%3D%3D"]] print(str)
Mr.Aleks Posted August 23, 2015 Posted August 23, 2015 · Hidden Hidden Si te returna eso tienes métodos para cambiar strings por otros, así como string.gsub, por ejemplo.
Sasu Posted August 23, 2015 Posted August 23, 2015 · Hidden Hidden Si te returna eso tienes métodos para cambiar strings por otros, así como string.gsub, por ejemplo. No funciona, el error se produce al crear el string.
UserToDelete Posted August 23, 2015 Author Posted August 23, 2015 https://gist.github.com/ignisdesign/4323051 La cosa es, la string es una variante. local _ = tostring([[ mp3link['link'] ]]):gsub("\"", ""):gsub("\\", "") y me returna: mp3link['link']
Tomas Posted August 24, 2015 Posted August 24, 2015 https://gist.github.com/ignisdesign/4323051 La cosa es, la string es una variante. local _ = tostring([[ mp3link['link'] ]]):gsub("\"", ""):gsub("\\", "") y me returna: mp3link['link'] ¿De dónde lo sacas?
UserToDelete Posted August 24, 2015 Author Posted August 24, 2015 https://gist.github.com/ignisdesign/4323051 La cosa es, la string es una variante. local _ = tostring([[ mp3link['link'] ]]):gsub("\"", ""):gsub("\\", "") y me returna: mp3link['link'] ¿De dónde lo sacas? local decodeURI do local function _(hex) return string.char(tonumber(hex, 16)) end function decodeURI(s) s = string.gsub(s, '%%(%x%x)', _) return s end end function getMp3LinkFromYoutubeURL (str) local mp3link = "" fetchRemote("http://YouTubeInMP3.com/fetch/?format=json&video="..str, function (response, errorno) outputDebugString(response) if response ~= 'ERROR' then mp3link = fromJSON(response) else error("Error ["..tostring(errorno).."] on get MP3 from Youtube URL") return 0 end end ) local _ = tostring([[ mp3link['link'] ]]):gsub("\"", ""):gsub("\\", "") return tostring(_) end --ejemplo --getMp3LinkFromYoutube('https://www.youtube.com/watch?v=i62Zjga8JOM')
Tomas Posted August 25, 2015 Posted August 25, 2015 A mi me funciona bien.. <~Kayla> Ares executed command: fetchRemote("http://YouTubeInMP3.com/fetch/?format=JSON&video=http://www.youtube.com/watch?v=i62Zjga8JOM", function (response) outputIRC(fromJSON(response)['link']) end) .:~Kayla:. Command results: true [boolean] .:~Kayla:. [url=http://youtubeinmp3.com/download/get/?i=XNGizydkSTmnyzMZtlHSum8dE4C1ucIDVEMBzdKRdRb7gQ8GAHYh3PlbIGNxiIyfRX82YwsvGhi5uvqj9UAXdA%3D%3D]http://youtubeinmp3.com/download/get/?i ... AXdA%3D%3D[/url]
Recommended Posts