egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with tcl, to search subtitles in 1 site

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
unb0rn
Voice


Joined: 08 Sep 2008
Posts: 26

PostPosted: Mon Sep 08, 2008 8:18 am    Post subject: Help with tcl, to search subtitles in 1 site Reply with quote

Hi, i'm trying to make a TCL that searches one website for subtitles, and then give me the link in the irc, but i can't get it to work...
I've been searching here, and in google, and i can't find anything like the one that i want.

I want the tcl to search this site: http://www.legendasdivx.com
I think the search link is this one,
http://www.legendasdivx.com/modules.php?name=Downloads&file=jz&d_op=search&op=_jz00

It's a Portuguese website.

CODE:

Quote:

set legendas(cmd) "!legendas"
set legendas(help) "\002!legendas\002 \<Filme>"
set legendas(url) "http://www.legendasxvid.net/modules.php?name=Downloads&d_op=search&min=0&query={ }&orderby=dateD"
setudef flag legendas

bind pub - $legendas(cmd) legendas:request

package require http
http::config -useragent "Mozilla/1.0"

proc legendas:request { nick uhost hand chan arg } {
if { [ lsearch -exact [ channel info $chan ] "+legendas" ] == -1 } { return }

global legendas
if {[string match -nocase $arg "help"] || [lindex $arg 0 ] == ""} {
putquick "privmsg $chan :$legendas(help)"
return
}
putlog "\002LEGENDAS\002: !legendas $arg -> $nick@$chan "

set url [append legendas(url) [string map {\ +} $arg]]
putlog "\002URL\002: $url"

set http [ http::geturl $url ]
set html [ http::data $http ]
set num 1

foreach line [ split $html "\n" ] {
if { [ regexp -- {^.*<br><font color\=#008000>(.+).*</font><a class.*$} $line all link ] } {
if { $num > 4 } { break }
incr num
regsub -all -- { -.*-\s*$} $link "" link
set risposta "$answer\002::\002 $link "
}
}
regsub -all -- {\s+} $answer " " answer
putquick "privmsg $chan :\037Legendas\037: $answer"
}


I appreciate the help, 'cos i really want this to work.


Last edited by unb0rn on Fri Sep 12, 2008 12:27 pm; edited 1 time in total
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Mon Sep 08, 2008 8:30 pm    Post subject: Reply with quote

Your building the url incorrectly.
Code:
Change:
set legendas(url) "http://www.legendasxvid.net/modules.php?name=Downloads&d_op=search&min=0&query={ }&orderby=dateD"

To:
set legendas(url) "http://www.legendasxvid.net/modules.php?name=Downloads&d_op=search&min=0&query=%%query%%&orderby=dateD"

Change:
set url [append legendas(url) [string map {\ +} $arg]]

To:
set url $legendas(url)
regsub {%%query%%} $url "[string map {" " "+"} $arg]" url

That should fix it for the most part, assuming your parsing is correct.
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
unb0rn
Voice


Joined: 08 Sep 2008
Posts: 26

PostPosted: Tue Sep 09, 2008 5:13 am    Post subject: Reply with quote

Thank's for the help, but i have no idea what's wrong, now with the url that you gave me, stills doesn't work.

I'm looking at the code, and i cant find the error.

If it isn't asking too much, could you kindly help me with the code?
Maybe a different one or something.
Back to top
View user's profile Send private message
unb0rn
Voice


Joined: 08 Sep 2008
Posts: 26

PostPosted: Tue Sep 16, 2008 8:02 pm    Post subject: Reply with quote

I even tried to use the normal google tcl, only changing the url, but it doesn't work.

Can you please help me?
Back to top
View user's profile Send private message
unb0rn
Voice


Joined: 08 Sep 2008
Posts: 26

PostPosted: Tue Sep 16, 2008 8:48 pm    Post subject: Reply with quote

I've tried another one, with the url that you gave me...


### Configuration settings ###

# the triggers: [seperate with spaces]
set google(triggers) "!legendas"

# flags needed to use the trigger [default=everyone]
set google(flags) "-|-"

# channels where the bot doesn't respond to triggers [seperate with spaces]
set google(nopub) ""

# flood protection: seconds between use of the triggers
# to disable: set it to 0
set google(antiflood) 5

# method to send the messages:
# 0 = Private message
# 1 = Public message
# 2 = Private notice
# 3 = Public notice
set google(method) 1

# show how many results? 1, 2 or 3??
set google(results) 3

# show every result on a new line? 0=no 1=yes
set google(perline) 0

set google(version) 0.4

if {[catch { package require http } err]} {
putlog "Cannot load [file tail [info script]]: Problem loading the http package: $err"
return 1
}

if {[info tclversion] < 8.1} {
putlog "Cannot load [file tail [info script]]: You need at least Tcl version 8.1 and you have Tcl version [info tclversion]."
return 1
}

foreach trigger [split $google(triggers)] {
bind pub $google(flags) $trigger google:pub
}
catch { unset trigger }

proc google:output {chan nick output} {
global google

switch $google(method) {
0 { putquick "PRIVMSG $nick :$output" }
1 { putquick "PRIVMSG $chan :$output" }
2 { putquick "NOTICE $nick :$output" }
3 { putquick "NOTICE $chan :$output" }
default { putquick "PRIVMSG $chan :$output" }
}
}

proc google:pub {nick uhost hand chan text} {
global lastbind google

if {[lsearch -exact $google(nopub) [string tolower $chan]] >= 0} { return 0 }

if {[string length [string trim [lindex $text 0]]] == 0} {
putquick "NOTICE $nick :Usage: $lastbind <keywords>"
return 0
}

if {[info exists google(floodprot)]} {
set diff [expr [clock seconds] - $google(floodprot)]
if {$diff < $google(antiflood)} {
putquick "NOTICE $nick :Trigger has just been used! Please wait [expr $google(antiflood) - $diff] seconds..."
return 0
}
catch { unset diff }
}
set google(floodprot) [clock seconds]

regsub -all { } [join $text] {+} search
set google(url) "http://www.legendasxvid.net/modules.php?name=Downloads&d_op=search&min=0&query=%%query%%&orderby=dateD"
set google(page) [http::config -useragent "Mozilla"]
if {[catch {set google(page) [http::geturl $google(url) -timeout 15000]} msg]} {
putquick "NOTICE $nick :Can't connect ($msg)"
return 0
}
set google(data) [http::data $google(page)]

if {$google(results) >= 1} {
regexp -nocase {related:(.*?)>} $google(data) t link1
}
if {$google(results) >= 2} {
regexp -nocase {related:.*?>.*?related:(.*?)>} $google(data) t link2
}
if {$google(results) >= 3} {
regexp -nocase {related:.*?>.*?related:.*?>.*?related:(.*?)>} $google(data) t link3
}

if {$google(perline) == 1} {
set separator "\n"
} else {
set separator "-"
}

if {[info exists link3]} {
set output "http://$link1 $separator http://$link2 $separator http://$link3"
} elseif {[info exists link2]} {
set output "http://$link1 $separator http://$link2"
} elseif {[info exists link1]} {
set output "http://$link1"
} else {
set output "Nothing found." <------------------------------------
}

regsub -all {%26} $output {\&} output
regsub -all {%3F} $output {?} output
regsub -all {%3D} $output {=} output

if {$google(perline) == 1} {
foreach line [split $output \n] {
google:output $chan $nick [string trim $line]
}
} else {
google:output $chan $nick [string trim $output]
}

catch { unset output separator t link1 link2 link3 }
catch { http::cleanup $google(page) }

return 0
}

putlog "Google script $google(version) loaded!"


On the irc, it shows: Nothing found.
even if i change that part, i have no ideia what to put there.
Back to top
View user's profile Send private message
unb0rn
Voice


Joined: 08 Sep 2008
Posts: 26

PostPosted: Wed Sep 17, 2008 6:48 am    Post subject: Reply with quote

unb0rn wrote:
I've tried another one, with the url that you gave me...


### Configuration settings ###

# the triggers: [seperate with spaces]
set google(triggers) "!legendas"

# flags needed to use the trigger [default=everyone]
set google(flags) "-|-"

# channels where the bot doesn't respond to triggers [seperate with spaces]
set google(nopub) ""

# flood protection: seconds between use of the triggers
# to disable: set it to 0
set google(antiflood) 5

# method to send the messages:
# 0 = Private message
# 1 = Public message
# 2 = Private notice
# 3 = Public notice
set google(method) 1

# show how many results? 1, 2 or 3??
set google(results) 3

# show every result on a new line? 0=no 1=yes
set google(perline) 0

set google(version) 0.4

if {[catch { package require http } err]} {
putlog "Cannot load [file tail [info script]]: Problem loading the http package: $err"
return 1
}

if {[info tclversion] < 8.1} {
putlog "Cannot load [file tail [info script]]: You need at least Tcl version 8.1 and you have Tcl version [info tclversion]."
return 1
}

foreach trigger [split $google(triggers)] {
bind pub $google(flags) $trigger google:pub
}
catch { unset trigger }

proc google:output {chan nick output} {
global google

switch $google(method) {
0 { putquick "PRIVMSG $nick :$output" }
1 { putquick "PRIVMSG $chan :$output" }
2 { putquick "NOTICE $nick :$output" }
3 { putquick "NOTICE $chan :$output" }
default { putquick "PRIVMSG $chan :$output" }
}
}

proc google:pub {nick uhost hand chan text} {
global lastbind google

if {[lsearch -exact $google(nopub) [string tolower $chan]] >= 0} { return 0 }

if {[string length [string trim [lindex $text 0]]] == 0} {
putquick "NOTICE $nick :Usage: $lastbind <keywords>"
return 0
}

if {[info exists google(floodprot)]} {
set diff [expr [clock seconds] - $google(floodprot)]
if {$diff < $google(antiflood)} {
putquick "NOTICE $nick :Trigger has just been used! Please wait [expr $google(antiflood) - $diff] seconds..."
return 0
}
catch { unset diff }
}
set google(floodprot) [clock seconds]

regsub -all { } [join $text] {+} search
set google(url) "http://www.legendasxvid.net/modules.php?name=Downloads&d_op=search&min=0&query=%%query%%&orderby=dateD"
set google(page) [http::config -useragent "Mozilla"]
if {[catch {set google(page) [http::geturl $google(url) -timeout 15000]} msg]} {
putquick "NOTICE $nick :Can't connect ($msg)"
return 0
}
set google(data) [http::data $google(page)]

if {$google(results) >= 1} {
regexp -nocase {related:(.*?)>} $google(data) t link1
}
if {$google(results) >= 2} {
regexp -nocase {related:.*?>.*?related:(.*?)>} $google(data) t link2
}
if {$google(results) >= 3} {
regexp -nocase {related:.*?>.*?related:.*?>.*?related:(.*?)>} $google(data) t link3
}

if {$google(perline) == 1} {
set separator "\n"
} else {
set separator "-"
}

if {[info exists link3]} {
set output "http://$link1 $separator http://$link2 $separator http://$link3"
} elseif {[info exists link2]} {
set output "http://$link1 $separator http://$link2"
} elseif {[info exists link1]} {
set output "http://$link1"
} else {
set output "Nothing found." <------------------------------------ THIS PART HERE
}

regsub -all {%26} $output {\&} output
regsub -all {%3F} $output {?} output
regsub -all {%3D} $output {=} output

if {$google(perline) == 1} {
foreach line [split $output \n] {
google:output $chan $nick [string trim $line]
}
} else {
google:output $chan $nick [string trim $output]
}

catch { unset output separator t link1 link2 link3 }
catch { http::cleanup $google(page) }

return 0
}

putlog "Google script $google(version) loaded!"


On the irc, it shows: Nothing found.
even if i change that part, i have no ideia what to put there.
Where i have " <------------ THIS PART HERE " if i don't edit that, it will show me on the IRC, what a wrote there, i think that now, the only problem is on the " set output ".
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber