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 

blu-ray.com script by dalys (current: blu-ray.com_1.2.tcl)
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
Ragman
Voice


Joined: 06 Jun 2010
Posts: 5

PostPosted: Thu Oct 14, 2010 12:53 pm    Post subject: Reply with quote

Any progress with the official version dalys?
Back to top
View user's profile Send private message
stu1818
Voice


Joined: 24 Oct 2010
Posts: 1

PostPosted: Sun Oct 24, 2010 6:26 am    Post subject: Reply with quote

could anybody tell me where i get uri.tcl from, this script looks good, i just cannot run it as i do not have uri.tcl

thanks

stu Smile
Back to top
View user's profile Send private message
Znuff
Voice


Joined: 17 May 2010
Posts: 9

PostPosted: Tue Aug 23, 2011 3:22 am    Post subject: Reply with quote

I've updated this again:

Fixed some issues with some movies not showing a release date.
uri.tcl can be found in the tcllib package. Most linux distributions should have that.

Code:

######################################################################################
# Blu-ray.com script made by dalys that search the website                           #
# http://www.blu-ray.com for movie titles and fetch info                             #
######################################################################################
#
# Bugs/Suggestions/Whatever contact: dalys@chokladboll.se
#
# <dalys> !bluray the dark knight
# <bot> "The Dark Knight (Blu-ray)" Release date: Dec 09, 2008 (Year: 2008  Length: 152 mins Rating: Rated PG-13 Studio: Warner Bros.)
#
# Requirements: http.tcl, uri.tcl
#
# Tested on eggdrop 1.6.18 & 1.6.19 & 1.6.20
#
# 1.3.1-coconut 2011-08-23 / znuffy@gmail.com
# - Fixed the release date for some movies (some movies with release date on the website
#   didn't show up in the script
#
# 1.3coconut 2010-09-23 / znuffy@gmail.com
# - Removed the -details option, too much work to maintain it between the layout changes
#   of blu-ray.com
# - Fixed and added new stuff for the layout/code changes of blu-ray.com.
# - Lowered default timeout value to 10seconds
#
# 1.2 2010-02-01
# - Blu-ray.com has been updated (with a better search function it seems)
#   and so has the script.
# - Moved the project to github.
#
# 1.1 2008-10-26
# - Fixed a broken regexp due to changes in blu-ray.com's html code
# - Replaced the replacevar function with regsub (replacevar was not part of standard TCL)
#   Thanks to speechles for taking his time and helping out with the above!
#
# 1.0 2008-10-05
# First release.
#
#
# Known issues:
# - Found one title with the release date set to "2009", which the script will mistake
# for the year the movie was made which is also just four digits.
#


#### CONFIG ####


# Channels were script can be used (the only config line you HAVE to change)
set bluray_availchans "#rsr"

# Channels were the result will be sent in PM
set bluray_quitechans "#chan2 #chan4"

# Output style
#
# IRC markup: bold = \002, underline = \037, reverse(italic in some clients) =  \026
# Example: %title is coming out \002%releasedate\002!
#
# Normal search (!bluray <title>)
# Variables available: %title %studio %year %releasedate %rating %length
# Default: "\"%title\" Release date: \002%releasedate\002 \(Year: %year Length: %length Rating: %rating Studio: %studio\)"
set bluray_outputstyle "\"%title\" Release date: \002%releasedate\002 \(Year: %year Length: %length Rating: %rating\)"

# Timeout, in ms (default: "20000")
set bluray_timeout "10000"

# What commands to respond to (default: !bluray !bd !br)

bind pub - .bd bluray_pub
bind pub - .br bluray_pub


#### END OF CONFIG ####


#### DO NOT EDIT BELOW, UNLESS YOU ACTUALLY KNOW WHAT YOU ARE DOING ####

set bluray_version "1.3.1-coconut"
package require http
package require uri

proc geturl_followRedirects {url args} {
    array set URI [::uri::split $url] ;# Need host info from here
    foreach x {1 2 3 4 5} {
        set token [eval [list http::geturl $url] $args]
        if {![string match {30[1237]} [::http::ncode $token]]} {return $token}
        array set meta [set ${token}(meta)]
        if {![info exist meta(Location)]} {
            return $token
        }
        array set uri [::uri::split $meta(Location)]
        unset meta
        if {$uri(host) == ""} { set uri(host) $URI(host) }
        # problem w/ relative versus absolute paths
        set url [eval ::uri::join [array get uri]]
    }
}


proc bluray_pub {nick uhost hand chan text} {
    global bluray_availchans bluray_quitechans bluray_timeout bluray_outputstyle
   
    set bluray_keywords $text
    set bluray_output $bluray_outputstyle
   
    if {([lsearch -exact $bluray_availchans $chan] == -1) && ($chan != "privmsg")} {return}
    if {([lsearch -exact $bluray_quitechans $chan] != -1) || ($chan == "privmsg")} {set chan $nick}
   
    if {[string match $text ""]} {
        puthelp "PRIVMSG $chan :Usage: !bluray <movie title>"
        return
    } else { set bluray_keywords [lrange $text 0 end] }
   
   
    set bluray_keywords [string map { " " "+" "%" "+" "&" "+" "*" "+" "." "+"} $bluray_keywords]
   
    #   set bluray_url "http://www.blu-ray.com/search/?quicksearch=1&section=movies&keyword=$bluray_keywords&sortby=popularity"
    set bluray_url "http://www.blu-ray.com/search/?quicksearch=1&section=movies&quicksearch_keyword=$bluray_keywords&searchbutton.x=0&searchbutton.y=0"
    catch {set page [geturl_followRedirects $bluray_url -timeout $bluray_timeout]} error
    if {[string match -nocase "*couldn't open socket*" $error]} {
        puthelp "PRIVMSG $chan :Error: Could not open socket to blu-ray.com, please try again later."
        ::http::cleanup $page
        return
    }
    if {[::http::status $page] == "timeout" } {
        puthelp "PRIVMSG $chan :Error: Timed out connecting to blu-ray.com, please try again later."
        ::http::cleanup $page
        return
    }
   
    set html [::http::data $page]
    ::http::cleanup $page
   
    set html [string map { "\r\n" "" "\n" "" "\\n" "" } $html]
   
    if {[regexp {<h3>(.*?)</h3></a>} $html match bluray_title] } {
       
        if {[regexp {<small style=\"color: #666666\">(.*?)</small>} $html match bluray_info] } {
            set bluray_infosplit [split $bluray_info "|"]
           
            set bluray_info_year "N/A"
            set bluray_info_studio "N/A"
            set bluray_info_releasedate "N/A"
            set bluray_info_rating "N/A"
            set bluray_info_length "N/A"
            for { set i 0 } { $i < 6 } { incr i } {
               
                set bluray_currentinfo [string trimleft [lindex $bluray_infosplit $i]]
                set bluray_currentinfo [string trimright $bluray_currentinfo]
               
                if {[regexp {^[0-9]{1,4}$} $bluray_currentinfo]} {
                    set bluray_info_year $bluray_currentinfo
                   
                }
                if {[regexp {^[0-9]{1,5}\smin$} $bluray_currentinfo]} {
                    set bluray_info_length $bluray_currentinfo
                }
                if {[regexp {((Q[0-9]\s|[A-z]{3}\s[0-9]{2},\s)[0-9]{4}|No\sRelease\sDate)} $bluray_currentinfo]} {
                    set bluray_info_releasedate $bluray_currentinfo
                }
                if {[regexp {^.*(R|r)ated.*$} $bluray_currentinfo]} {
                    set bluray_info_rating $bluray_currentinfo
                }
                if {![regexp {^[0-9]{4}$} $bluray_currentinfo] && ![regexp {^[0-9]*\smin$} $bluray_currentinfo] && ![regexp {^[A-z]{3}\s[0-9]{1,2},\s[0-9]{4}} $bluray_currentinfo] && ![regexp {^.*(R|r)ated.*$} $bluray_currentinfo] && ![regexp {((Q[0-9]\s|[A-z]{3}\s[0-9]{2},\s)[0-9]{4}|No\sRelease\sDate)} $bluray_currentinfo] && [regexp {[A-z0-9]{2,60}} $bluray_currentinfo]} {
                    set bluray_info_studio $bluray_currentinfo
                }
               
            }
           
            regsub -all -nocase "%title" $bluray_output $bluray_title bluray_output
            regsub -all -nocase "%studio" $bluray_output $bluray_info_studio bluray_output
            regsub -all -nocase "%year" $bluray_output $bluray_info_year bluray_output
            regsub -all -nocase "%length" $bluray_output $bluray_info_length bluray_output
            regsub -all -nocase "%rating" $bluray_output $bluray_info_rating bluray_output
            regsub -all -nocase "%releasedate" $bluray_output $bluray_info_releasedate bluray_output
           
            puthelp "PRIVMSG $chan :$bluray_output"
           
        } else {
            puthelp "PRIVMSG $chan :Could not retrieve coconut about $bluray_title"
        }
    } elseif {[regexp {<h2 class="title">(.*?)</h2>} $html match bluray_title]} {
        if {[regexp {<span class="subheading" style="color: #666666">(.*?)</span><br><br>} $html matched bluray_info]} {
           
            regsub -all {<[^>]+>} $bluray_info { } bluray_info_stripped
           
            set bluray_infosplit [split $bluray_info_stripped "|"]
           
            set bluray_info_year "N/A"
            set bluray_info_studio "N/A"
            set bluray_info_releasedate "N/A"
            set bluray_info_rating "N/A"
            set bluray_info_length "N/A"
           
            for { set i 0 } { $i < 5 } { incr i } {
               
                set bluray_currentinfo [string trimleft [lindex $bluray_infosplit $i]]
                set bluray_currentinfo [string trimright $bluray_currentinfo]
               
                if {[regexp {^[0-9]{1,4}$} $bluray_currentinfo]} {
                    set bluray_info_year $bluray_currentinfo
                }
                if {[regexp {^[0-9]{1,5}\smin$} $bluray_currentinfo]} {
                    set bluray_info_length $bluray_currentinfo
                }
                if {[regexp {((Q[0-9]\s|[A-z]{3}\s[0-9]{2},\s)[0-9]{4}|No\sRelease\sDate)} $bluray_currentinfo]} {
                    set bluray_info_releasedate $bluray_currentinfo
                }
                if {[regexp {^.*(R|r)ated.*$} $bluray_currentinfo]} {
                    set bluray_info_rating $bluray_currentinfo
                }
                if {![regexp {^[0-9]{4}$} $bluray_currentinfo] && ![regexp {^[0-9]*\smin$} $bluray_currentinfo] && ![regexp {^[A-z]{3}\s[0-9]{1,2},\s[0-9]{4}} $bluray_currentinfo] && ![regexp {^.*(R|r)ated.*$} $bluray_currentinfo] && !  [regexp {((Q[0-9]\s|[A-z]{3}\s[0-9]{2},\s)[0-9]{4}|No\sRelease\sDate)} $bluray_currentinfo] && [regexp {[A-z0-9]{2,60}} $bluray_currentinfo]} {
                    set bluray_info_studio $bluray_currentinfo
                }
               
            }
           
            regsub -all -nocase "%title" $bluray_output $bluray_title bluray_output
            regsub -all -nocase "%studio" $bluray_output $bluray_info_studio bluray_output
            regsub -all -nocase "%year" $bluray_output $bluray_info_year bluray_output
            regsub -all -nocase "%length" $bluray_output $bluray_info_length bluray_output
            regsub -all -nocase "%rating" $bluray_output $bluray_info_rating bluray_output
            regsub -all -nocase "%releasedate" $bluray_output $bluray_info_releasedate bluray_output
           
           
            puthelp "PRIVMSG $chan :$bluray_output"
           
        } else {
            puthelp "PRIVMSG $chan :The coconut is broken."
        }
    } else {
       
        if {[regexp {alt=\"United\sKingdom\"\stitle=\"United\sKingdom\"\s\/><br><br>(.{100,250}?)<br><br><h5>} $html match bluray_noresult] } {
            set bluray_noresult [string map {"<b>" "\002" "</b>" "\002"} $bluray_noresult]
            regsub -all "results" $bluray_noresult "coconuts" bluray_coconuts
            puthelp "PRIVMSG $chan :$bluray_coconuts"
        } else {
            puthelp "PRIVMSG $chan :Could not fetch any search result or error message. The coconut is probably outdated."
        }
       
    }
   
   
}

putlog "blu-ray.com script $bluray_version: LOADED"


http://z.linge-ma.ws/eggdrop/bluray.tcl
Back to top
View user's profile Send private message
Arkadietz
Halfop


Joined: 14 Jul 2006
Posts: 67
Location: cat /dev/zero > /dev/null;

PostPosted: Tue Sep 20, 2011 12:48 pm    Post subject: Reply with quote

hey, can you make it works with 1.8 and without additional .tcls or packages.
_________________
On a unix system everything is a file ; if something is not a file , it is a proccess.
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
zoggy
Voice


Joined: 24 Jun 2013
Posts: 4

PostPosted: Mon Jun 24, 2013 4:53 pm    Post subject: Reply with quote

So today I stumbled upon the bluray.tcl. I tried the modified 1.3.1 version but ran into some issues. Went back to the 1.2 and it also had issues (single results wouldnt work.. due to redirect). So to make this script have less need of staying up to date with blu-ray.com changes.. I modified so it spits out the movie info as the website shows it. Instead of trying to scrape each piece of data and figure out which var to put them in. (Since I don't mind seeing it in the x|x|x format anyways).

I've added a strip html function (remove html from info line) and urlencode (bluray keywords) as well as strip the 'Blu-ray' part from the parsed title.
The search currently is specify to search within the US, you can easily change this by finding "quicksearch_country=US" in the URL and changing the country to what you need (or use 'all' for all).

before:
Quote:

!bluray Batman Begins
<bot> "Batman Begins Blu-ray" Release date: N/A (Year: 2005 Length: N/A Rating: Rated PG-13 Studio: Region A <font style="color: #999999">(B, C untested)</font>)


now:
Quote:

!bluray Batman Begins
<bot> Batman Begins :: Warner Bros. | 2005 | 140 min | Rated PG-13 | Region free | Jul 08, 2008


Code:

######################################################################################
# Blu-ray.com script made by dalys that search the website                           #
# http://www.blu-ray.com for movie titles and fetch info                             #
######################################################################################
#
# Bugs/Suggestions/Whatever contact: dalys@chokladboll.se
#
# <user> !bluray iron man 3
# <bot> Iron Man 3 :: Disney / Buena Vista | 2013 | 140 min | Rated PG-13 | Region A (B, C untested) | Aug 27, 2013
#
# Requirements: http.tcl, uri.tcl (tcllib)
#
# Tested on eggdrop 1.6.18 & 1.6.19
#
#### CONFIG ####


# Channels were script can be used (the only config line you HAVE to change)
set bluray_availchans "#chan1 #chan2 #chan3"

# Channels were the result will be sent in PM
set bluray_quitechans "#chan2"

# Output style
#
# IRC markup: bold = \002, underline = \037, reverse(italic in some clients) =  \026
# Example: %title is coming out \002%releasedate\002!
#
# Normal search (!bluray <title>)
set bluray_outputstyle "\002%title\002 :: %info"

# Timeout, in ms (default: "20000")
set bluray_timeout "10000"

# What commands to respond to (default: !bluray !bd !br)

bind pub - !bluray bluray_pub
bind pub - !blu-ray bluray_pub

#### END OF CONFIG ####


#### DO NOT EDIT BELOW, UNLESS YOU ACTUALLY KNOW WHAT YOU ARE DOING ####

set bluray_version "1.3z"
package require http
package require uri

proc strip_html_tags { htmlText } {
    regsub -all {<[^>]+>} $htmlText "" newText
    return $newText
}

# http://rosettacode.org/wiki/URL_encoding#Tcl
proc urlencode {str} {
    # Encode all except "unreserved" characters; use UTF-8 for extended chars.
    # See http://tools.ietf.org/html/rfc3986 §2.4 and §2.5
    set uStr [encoding convertto utf-8 $str]
    set chRE {[^-A-Za-z0-9._~\n]};      # Newline is special case!
    set replacement {%[format "%02X" [scan "\\\0" "%c"]]}
    return [string map {"\n" "%0A"} [subst [regsub -all $chRE $uStr $replacement]]]
}

# http://wiki.tcl.tk/11831
proc geturl_followRedirects {url args} {
    array set URI [::uri::split $url] ;# Need host info from here
    foreach x {1 2 3 4 5} {
        set token [eval [list http::geturl $url] $args]
        if {![string match {30[1237]} [::http::ncode $token]]} {return $token}
        array set meta [set ${token}(meta)]
        if {![info exist meta(Location)]} {
            return $token
        }
        array set uri [::uri::split $meta(Location)]
        unset meta
        if {$uri(host) == ""} { set uri(host) $URI(host) }
        # problem w/ relative versus absolute paths
        set url [eval ::uri::join [array get uri]]
    }
}

proc bluray_pub {nick uhost hand chan text} {
    global bluray_availchans bluray_quitechans bluray_timeout bluray_outputstyle

    set bluray_keywords $text
    set bluray_output $bluray_outputstyle

    if { ([lsearch -exact $bluray_availchans $chan] == -1) && ($chan != "privmsg") } { return }
    if { ([lsearch -exact $bluray_quitechans $chan] != -1) || ($chan == "privmsg") } { set chan $nick }

    if { [string match $text ""] } {
        puthelp "PRIVMSG $chan :Usage: !bluray <movie title>"
        return
    } else {
        set bluray_keywords [lrange $text 0 end]
    }

    # currently the webpage defaults to the geo-dns country, should force this to ALL?
    # http://www.blu-ray.com/setcountry.php?country=all

    set bluray_url "http://www.blu-ray.com/search/?quicksearch=1&quicksearch_country=US&section=bluraymovies&sortby=popularity&submit=Search&action=search&quicksearch_keyword="
    append bluray_url [urlencode [string trimleft $bluray_keywords]]
    puts $bluray_url

    # this wont work when its a single result, since the website redirects to its page..
    #catch {set page [::http::geturl $bluray_url -timeout $bluray_timeout]} error

    # thus this redirect routine is needed, which requires tcllib package to be installed
    catch {set page [geturl_followRedirects $bluray_url -timeout $bluray_timeout]} error

    if { [string match -nocase "*couldn't open socket*" $error] } {
        puthelp "PRIVMSG $chan :Error: Could not open socket to blu-ray.com, please try again later."
        ::http::cleanup $page
        return
    }
    if { [::http::status $page] == "timeout" } {
        puthelp "PRIVMSG $chan :Error: Timed out connecting to blu-ray.com, please try again later."
        ::http::cleanup $page
        return
    }

    set html [::http::data $page]
    ::http::cleanup $page

    # flatten html source so that its easier to match more specific lines of code via regexp
    set html [string map { "\r\n" "" "\n" "" "\\n" "" } $html]

    if { [regexp {class="noline"><h3>(.*?)</h3></a>} $html match bluray_title] } {

        set bluray_title [string map {" Blu-ray" ""} $bluray_title]

        if { [regexp {<br><small style=\"color: #666666\">(.*?)</small><br>} $html match bluray_info] } {
            set bluray_info [strip_html_tags $bluray_info]
            regsub -all -nocase "%title" $bluray_output $bluray_title bluray_output
            regsub -all -nocase "%info" $bluray_output $bluray_info bluray_output
            puthelp "PRIVMSG $chan :$bluray_output"
        } else {
            puthelp "PRIVMSG $chan :Could not retrieve info about $bluray_title"
        }

    } elseif { [regexp {<h1 itemprop="itemReviewed"><a.*?>(.*?)</a>} $html match bluray_title] } {

        if {[regexp {<span class="subheading" style="color: #666666">(.*?)</span><br><br>} $html matched bluray_info]} {
            set bluray_info [strip_html_tags $bluray_info]
            regsub -all -nocase "%title" $bluray_output $bluray_title bluray_output
            regsub -all -nocase "%info" $bluray_output $bluray_info bluray_output
            puthelp "PRIVMSG $chan :$bluray_output"
        } else {
            puthelp "PRIVMSG $chan :Could not retrieve info about $bluray_title"
        }

    } else {

        if {[regexp {</a></div><br><br>(.{100,250}?)<br><br><h5>} $html match bluray_noresult] } {
            set bluray_noresult [string map {"<b>" "\002" "</b>" "\002"} $bluray_noresult]
            puthelp "PRIVMSG $chan :$bluray_noresult"
        } else {
            puthelp "PRIVMSG $chan :Could not fetch any search result, try searching for a more specific title name."
        }

    }

}

putlog "Blu-ray.com script $bluray_version by dalys / zoggy LOADED"
Back to top
View user's profile Send private message
fr3n
Voice


Joined: 02 Dec 2005
Posts: 16

PostPosted: Fri Jun 28, 2013 12:35 pm    Post subject: Reply with quote

Works like a charm!

[18:27] <@fren> !bluray Django unchained
[18:27] <pruts> Django Unchained :: Starz / Anchor Bay | 2012 | 165 min | Rated R | Region A (locked) | Apr 16, 2013
Back to top
View user's profile Send private message
zoggy
Voice


Joined: 24 Jun 2013
Posts: 4

PostPosted: Fri Apr 24, 2015 9:42 am    Post subject: Reply with quote

update for the script to make it work again, have to pass cookie to show the old layout so it can be parsed:

in the geturl_followRedirects proc change this one line

from:
Code:

        set token [eval [list http::geturl $url] $args]


to:
Code:

        set token [eval [list http::geturl $url -headers {Cookie listlayout_7=full}] $args]
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 -> Script Support & Releases All times are GMT - 4 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
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