News
:
READ THE
RULES
Home
Forum
Help
Search
Calendar
Login
Register
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
September 07, 2010, 10:16:29 PM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Light Blue
Light Navy
Light Silver
Light Turquoise
Light Green
Light Olive
Light Golden
Light Brown
Light Red
Light Rose
Light Lilac
Light Violet
The PtokaX Portal
>
Forum
>
Client-based LUA scripting
>
Your Developing Problems
>
Lua socket.http for a client?
Pages: [
1
]
Go Down
« previous
next »
Print
Author
Topic: Lua socket.http for a client? (Read 225 times)
0 Members and 1 Guest are viewing this topic.
pzf
Junior Member
Karma: +0/-0
Offline
Posts: 15
Lua socket.http for a client?
«
on:
July 27, 2010, 08:36:25 PM »
Hello everyone,
First of all I want to tell you that I'm a complete newbie in Lua or scripting, so please if you explain to me something, do it like you would explain it to an idiot, LOL. (I can RTFM so I'm not that bad if you point me to the proper direction
)
I am trying to make a script for BCDC++ and VLC media player, it should retrieve the "127.0.0.1:8080/nowplaying.html" that I have setup already and post it in the chat. But I have problems with setting up the socket library, I have tested PXLuaSocket-2.0.2 that was intended for PtokaX, but I have problems with it, I get errors when I try to use it in my script to connect to the VLC webserver:
[21:34:26] LUA ERROR: (vlcnp.lua: ownChatOut) C:\Users\[UserName]\Documents\BCDC++\scripts\vlcnp.lua:8: loop or previous error loading module 'socket.http'
I've searched for another compiled one but I can't find. Source does me no good, I have no compiler nor I know how to use one.
So I was wondering if someone could help me with that, here is my script so far:
Code:
host = "127.0.0.1"
port = ":8080"
file = "/nowplaying.html"
dcpp:setListener( "ownChatOut", "vlcnp",
function ( hub, text )
local http = require("socket.http")
local txt = DC():FromUtf8(text)
local prefix = string.sub(txt, 1, 1)
if prefix == "+" or prefix == "!" then
return
elseif prefix == "/" then
local cmd = string.sub(txt, 2)
string.lower(cmd)
if cmd == "vlc" then
np = http.request(host..port..page)
hub:sendChat(np)
return 1
else
return
end
else
msg = txt
end
hub:sendChat(msg)
return 1
end
)
DC():PrintDebug(" ** Loaded vlcnp.lua **")
«
Last Edit: July 28, 2010, 12:24:50 AM by pzf
»
Logged
lUk3f1l3w4lK3R
Junior Member
Karma: +3/-0
Offline
Posts: 22
Re: Lua socket.http for a client?
«
Reply #1 on:
July 27, 2010, 10:02:31 PM »
I dont know if it will help cause i never wrote a client side script but you can get another LUASocket library here:
http://luaforge.net/frs/?group_id=23&release_id=837
cheers
Logged
Mutor
Global Moderator
Forum God
Karma: +372/-18
Offline
Posts: 3 631
To err is human, to arr is pirate...
Re: Lua socket.http for a client?
«
Reply #2 on:
July 27, 2010, 11:31:44 PM »
PXLuaSocket-2.0.2 as the name indicates is for use in PtokaX.
It will not work without errors in your client. The docs in the
Lua Socket 2.0 package are all you need. I noticed you were
trying to pickup on 127.0.0.1:8080/nowplaying.html with
the socket lib. If this [as it seems to be] is a local path
that is accessible by the hub computer, then it would
be best to just read that file with the Lua io lib and
parse the information necessary.
Logged
Respectfully,
Mutor
=-=-=-=-=-=-=-==-=-=-=
[
Ptokax Admins Hub
] Ptokax Help Hub
[
Mutor's Ptokax Archive Website
] Scripting Forum
[
Dynamic Downloads
] API 2
[
Microsoft IIS serving PxWeb 1.0d
] API 2
[
WebReg 1.1.2.0
] Web Based Hub Reg
pzf
Junior Member
Karma: +0/-0
Offline
Posts: 15
Re: Lua socket.http for a client?
«
Reply #3 on:
July 28, 2010, 12:36:28 AM »
Mutor, if I open it locally I will get "<vlc id="value" param1="'ARTIST' vlc_get_meta"/> - <vlc id="value" param1="'TITLE' vlc_get_meta"/>" not the current file playing. I need to get it through the webserver of VLC.
lUk3f1l3w4lK3R, thanks but I still get that error even with the libraries from that link:
Quote
[01:13:20] LUA ERROR: (vlcnp.lua: ownChatOut) C:\Users\s3m0\Documents\BCDC++\scripts\vlcnp.lua:8: loop or previous error loading module 'socket.http'
Maybe I'm not putting the files in the proper folder? I was trying in the install folder of BCDC++ and also in the settings folder but still the same problem. If I remove the libraries the error is:
Quote
[01:34:04] LUA ERROR: (vlcnp.lua: ownChatOut) C:\Users\s3m0\Documents\BCDC++\scripts\vlcnp.lua:8: module 'socket.http' not found:
no field package.preload['socket.http']
no file '.\socket\http.lua'
no file 'C:\Program Files\BCDC++\lua\socket\http.lua'
no file 'C:\Program Files\BCDC++\lua\socket\http\init.lua'
no file 'C:\Program Files\BCDC++\socket\http.lua'
no file 'C:\Program Files\BCDC++\socket\http\init.lua'
no file '.\socket\http.dll'
no file 'C:\Program Files\BCDC++\socket\http.dll'
no file 'C:\Program Files\BCDC++\loadall.dll'
no file '.\socket.dll'
no file 'C:\Program Files\BCDC++\socket.dll'
no file 'C:\Program Files\BCDC++\loadall.dll'
So I think that C:\Program Files\BCDC++\ is the proper folder. This leads me to thinking that the problem is again the library
Any suggestions?
Logged
Mutor
Global Moderator
Forum God
Karma: +372/-18
Offline
Posts: 3 631
To err is human, to arr is pirate...
Re: Lua socket.http for a client?
«
Reply #4 on:
July 28, 2010, 12:40:56 AM »
The root of your client is the proper place.
You shouldn't call the lib in every ownChatOut
listener. It will try to load the lib every time you
chat. You only need load the socket lib once,
preferably first.
«
Last Edit: July 28, 2010, 12:43:25 AM by Mutor
»
Logged
Respectfully,
Mutor
=-=-=-=-=-=-=-==-=-=-=
[
Ptokax Admins Hub
] Ptokax Help Hub
[
Mutor's Ptokax Archive Website
] Scripting Forum
[
Dynamic Downloads
] API 2
[
Microsoft IIS serving PxWeb 1.0d
] API 2
[
WebReg 1.1.2.0
] Web Based Hub Reg
pzf
Junior Member
Karma: +0/-0
Offline
Posts: 15
Re: Lua socket.http for a client?
«
Reply #5 on:
July 28, 2010, 01:04:58 AM »
OK I understand, this is what I did firstly and had the same error. Then I had a look at some other scripts that use that lib and changed it for testing, though they were for PtokaX, not a client. I will fix it, but still it doesn't work and it gives me the same error, just on another row.
Edit: Anyone ever managed to use the socks lib in a client?
«
Last Edit: July 28, 2010, 12:04:59 PM by pzf
»
Logged
pzf
Junior Member
Karma: +0/-0
Offline
Posts: 15
Re: Lua socket.http for a client?
«
Reply #6 on:
July 31, 2010, 01:33:01 PM »
I gave up on the socks lib, can't get it to work in my client.
Found out that VLC has some Lua support to, but coudn't make it work, it's either bugged like hell or I can't seem to understand it, the documentation sucks. My idea was to write the song in a file and then read it with BCDC++ but to hell with it.
Tried using os.execute() with wget and download the html file, then read it with the script, this works but when I use os.execute() it pops up a cmd window, which is not elegant at all. Did so many things in attempt to hide the cmd window with no succes.
I'm out of ideas now.
Logged
Mutor
Global Moderator
Forum God
Karma: +372/-18
Offline
Posts: 3 631
To err is human, to arr is pirate...
Re: Lua socket.http for a client?
«
Reply #7 on:
July 31, 2010, 01:51:15 PM »
Well you can write a hub side script.
Logged
Respectfully,
Mutor
=-=-=-=-=-=-=-==-=-=-=
[
Ptokax Admins Hub
] Ptokax Help Hub
[
Mutor's Ptokax Archive Website
] Scripting Forum
[
Dynamic Downloads
] API 2
[
Microsoft IIS serving PxWeb 1.0d
] API 2
[
WebReg 1.1.2.0
] Web Based Hub Reg
pzf
Junior Member
Karma: +0/-0
Offline
Posts: 15
Re: Lua socket.http for a client?
«
Reply #8 on:
July 31, 2010, 02:00:04 PM »
Yeah, but I don't host the hub, I'm just an admin there and the owner will probably just laugh at me when I tell her that I want the hub to run a script which I could use for my VLC Now Playing feature.
Oh and I would like to use it in all hubs, so client side is much better for this purpose.
«
Last Edit: July 31, 2010, 02:02:36 PM by pzf
»
Logged
Mutor
Global Moderator
Forum God
Karma: +372/-18
Offline
Posts: 3 631
To err is human, to arr is pirate...
Re: Lua socket.http for a client?
«
Reply #9 on:
July 31, 2010, 02:39:06 PM »
As I find it's your intent to spam hubs you don't
own, I'm laughing too. Let me guess, another DJ?
Some DC clients already have a plugin interface to
return now playing status from winamp, windows
media player, windows media player classic etc.
Perhaps you can simply annoy others with these.
Logged
Respectfully,
Mutor
=-=-=-=-=-=-=-==-=-=-=
[
Ptokax Admins Hub
] Ptokax Help Hub
[
Mutor's Ptokax Archive Website
] Scripting Forum
[
Dynamic Downloads
] API 2
[
Microsoft IIS serving PxWeb 1.0d
] API 2
[
WebReg 1.1.2.0
] Web Based Hub Reg
pzf
Junior Member
Karma: +0/-0
Offline
Posts: 15
Re: Lua socket.http for a client?
«
Reply #10 on:
July 31, 2010, 03:45:56 PM »
In the hubs where I reside most people do that and we do not frown upon it like spam...
I can see that you think in another way, everyone is free to have their own opinion about it, if I ever come along in a hub of your authority feel free to enforce your opinion on me.
I know that clients have option for other players, I just wanted to make one for VLC myself.
Logged
Mutor
Global Moderator
Forum God
Karma: +372/-18
Offline
Posts: 3 631
To err is human, to arr is pirate...
Re: Lua socket.http for a client?
«
Reply #11 on:
July 31, 2010, 04:45:19 PM »
Quote from: pzf on July 31, 2010, 03:45:56 PM
In the hubs where I reside most people do that and we do not frown upon it like spam...
Quote from: pzf on July 31, 2010, 02:00:04 PM
the owner will probably just laugh at me when I tell her that I want the hub to run a script which I could use for my VLC Now Playing feature.
Well which is it?
Logged
Respectfully,
Mutor
=-=-=-=-=-=-=-==-=-=-=
[
Ptokax Admins Hub
] Ptokax Help Hub
[
Mutor's Ptokax Archive Website
] Scripting Forum
[
Dynamic Downloads
] API 2
[
Microsoft IIS serving PxWeb 1.0d
] API 2
[
WebReg 1.1.2.0
] Web Based Hub Reg
pzf
Junior Member
Karma: +0/-0
Offline
Posts: 15
Re: Lua socket.http for a client?
«
Reply #12 on:
July 31, 2010, 05:48:05 PM »
The funny thing is using such a script hub side. That is what I meant, not the use of such feature.
Logged
Mutor
Global Moderator
Forum God
Karma: +372/-18
Offline
Posts: 3 631
To err is human, to arr is pirate...
Re: Lua socket.http for a client?
«
Reply #13 on:
July 31, 2010, 06:51:05 PM »
Well it certainly can be done client side and perhaps should be.
It seems to me you only need HTML Get and not the full socket lib.
To that end you can use [
webGet
]
Quote
A Lua 5.1 module to download files and XML/RDF triples from internet. This module provides also a XML SAX parser to analyse XML dowloaded files. Uses WinInet (allows HTTP/HTTPS/FTP, cookies, a download cache and http proxy).
It loads fine in RSX++ for me and so it should for you in BCDC++
Logged
Respectfully,
Mutor
=-=-=-=-=-=-=-==-=-=-=
[
Ptokax Admins Hub
] Ptokax Help Hub
[
Mutor's Ptokax Archive Website
] Scripting Forum
[
Dynamic Downloads
] API 2
[
Microsoft IIS serving PxWeb 1.0d
] API 2
[
WebReg 1.1.2.0
] Web Based Hub Reg
pzf
Junior Member
Karma: +0/-0
Offline
Posts: 15
Re: Lua socket.http for a client?
«
Reply #14 on:
July 31, 2010, 08:35:57 PM »
On my first test it worked like a charm, thanks a lot Mutor. I just need to read the documentation to get the hang of it.
Logged
Pages: [
1
]
Go Up
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Forum
-----------------------------
=> News
-----------------------------
PtokaX
-----------------------------
=> FAQ section
=> Support
=> Bugs
=> Feature Proposals
-----------------------------
Lua 5.1.x Scripts (for PtokaX 0.4.0.0 and newer)
-----------------------------
=> Request for scripts
=> Conversion Requests
=> Finished Scripts
=> Help with scripts
=> HOW-TO's
=> AllInOne Scripts
===> DiXBoT
=====> DiXBoT - Support
=====> DiXBoT - Bug Reports
=====> DiXBoT - Feature Requests
=====> DiXBoT - Custom modules
=====> DiXBoT - General
=====> DiXBoT Manager
===> Grimoire
=====> Grimoire - Bugs
=====> Grimoire - Requests
=====> Grimoire - Support
===> PtokaX Remote Admin
=====> Support
=====> Bug reports
=====> Feature requests
===> PGE
===> Terminator 2nd Generatation
=====> Bug reports
=====> Feature requests
=====> Support
=====> GUI
-----------------------------
Development Section
-----------------------------
=> PtokaX Development Versions
=> HOW-TO's
===> HOW-TO requests
=> LUA & PtokaX-Scripting-Interface
=> Extensions for PXLUA
=> Lua tools
=> Your Developing Problems
-----------------------------
Client-based LUA scripting
-----------------------------
=> HOWTOs
===> Request for HOWTOs
=> Your Developing Problems
=> Finished Scripts
=> Request for scripts
=> General discussion
-----------------------------
Stuff
-----------------------------
=> The PtokaX Admins' Hub
=> Guest Area
=> Offtopic
=> Your opinions about the forum
=> Links
=> Oldies but Goldies
-----------------------------
Archive
-----------------------------
=> Archived News
=> Archived 5.1 boards
===> AllInOne Scripts
=====> DiXBoT
=======> DiXBoT - Support
=======> DiXBoT - Bug Reports
=======> DiXBoT - Feature Requests
=======> DiXBoT - Custom modules
=======> DiXBoT - General
=====> Grimoire
=======> Grimoire - Bugs
=======> Grimoire - Requests
=======> Grimoire - Support
=====> Terminator
=====> RoboCop
=======> RoboCop - Support
=======> RoboCop - Requests
=======> RoboCop - Bugs
=====> Leviathan
=======> Leviathan - Support
=======> Leviathan - Requests
=======> Leviathan - Bugs
=====> Guardian 5
=====> P§ÿGúârÐ Edition
=====> LawMaker
=====> DESTiNATiON
=======> DESTiNATiON Bugs
=======> DESTiNATiON Support
=======> DESTiNATiON Feature Requests
===> HOW-TO's
=====> Old HOW-TO's
===> Help with scripts
===> Finished Scripts
===> Conversion Requests
===> Request for scripts
=> Archived 5.0 boards
===> Finished Scripts
===> Request for scripts
===> Help with scripts
===> AllInOne Scripts
=====> Guardian 5
=====> Terminator
=====> RoboCop
=======> Requests
=======> Bug reports
=======> Support
=====> Grimoire
=======> Grimoire - Bugs
=======> Grimoire - Requests
=======> Grimoire - Support
=> Archived 4.0 boards
===> Request for Lua 4 scripts
===> Finished Lua 4 scripts
===> Help with Lua 4 scripts
===> ChannelBot
Loading...