youtube script
#1
bonjour, j'ai un script youtube, qui marche trés bien, car il détecte sous:

http://www.youtube.com/watch?v=ZnYGp6IAB...ture=share

mais j'aimerais qu'il détecte aussi : http://youtu.be/ZnYGp6IABoU

comment faut faire?
Répondre Avertir
#2
Salut,

D'abors nous montrer ton code qui détecte http://www.youtube.com....
Répondre Avertir
#3
J'ai posté le code en pièce jointe
Répondre Avertir
#4
Re,

Bon déjà ton tcl je l'ai viré direct..
Je transmets un autre tcl qui pour moi et bien mieux.

Ensuite j'ai modifié le youtube par youtu comme c'est ce que le bot doit rechercher je me suis pas compliqué exemple :

Citation :[17:11:33] ( @alias_angelius ) .compile youtube.tcl
[17:11:33] ( @Talk-Me ) Compilation De youtube.tcl...
[17:11:33] ( @Talk-Me ) pas d'erreur
[17:11:36] ( @alias_angelius ) !tcl rehash
[17:11:37] ( @Talk-Me ) Tcl:
[17:11:39] ( @alias_angelius ) http://www.youtube.com/watch?v=sEhy-RXkNo0
[17:11:41] ( @Talk-Me ) You Tube "Rihanna - Man Down"
[17:11:46] ( @alias_angelius ) ok
[17:11:50] ( @alias_angelius ) http://youtu.be/ZnYGp6IABoU
[17:11:52] ( @Talk-Me ) You Tube "Stamina & AKi La Machine - Le Futur Aux Trousses (2011)"

Je join le tcl dans la modification du post car apparemment ont peut pas faire si ont fait pas comme ça bref test comme ça et tu verras Smile
Répondre Avertir
#5
oué mais non, j'compte garde la même syntaxe avec le nombre de vues...
Répondre Avertir
#6
explique
Répondre Avertir
#7
Oui

Zyrte›http://www.youtube.com/watch?v=qb8dHgszSpo&list=FLtz8m-ESIGkFQMrxuVg46aQ&index=220
‹+Youtube› 'alien project vs raja ram @ heineken sundance eilat' ( 74:20 ) Viewed 2 364

pas grave sinon mais je changerais pas pour un autre script youtube.
Répondre Avertir
#8
Je suis interessé par ton script Zyrte, peux tu le partager ?
Répondre Avertir
#9
Salut Cain tien j'en et trouver un :

tcl
# ourTube.tcl 1.0.2010 - v.DNS777 -
# This file search the web target and show relevant information about.
# Is posible define a YouTube account and the bot will log in. Useful
# when the link are for adult people i.e. It will show the first link
# that finds in a whole phrase.
#
# Copyright (c) 2007-2009 Eggdrop Spain 12-april-2009
#   HackeMate (Sentencia) Sentencia@eggdrop.es
#
# This program is free software; you can redistribute it and/or
# modify it _only for your own use_
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
#
# Please, use the email to contact with the author for let him know about all
# what you could do. Everyone wants develop his software as well.
#
#                   Thank you for feed my empiric life.
#
# If you like, you can contact with the author to suggest him features. By the
# way, do not ask him to make Login, he is working on that.

# This is what you need to get this script work:
# Type in partyline: .chanset #channel +ourtube

# Changelog:
#   Fixes:
#	Fixed showin views proper, some minimal fixes, and cutted out autoupdate, feedback feature and search (((DNS777)))
#       Resolved Tcl error [otPub]: can't read "views": no such variable (((? this was not fixed dude!)))
#       Resolved eternal ignore-protection  issue
#
#   Added features:
#       Now will forward to new location 302 http code received when pasting
#       http://youtube. links
#       Explicit message when 404 error (not found)
#       All non 200, 302, 303, 404 errors will stop the procedure showing proper reason
#       -*- IMPORTANT -*-
#       Auto Update checker: You can verify if your ourTube copy is the lastest
#       version available typing .ourtube update in partyline (((? killed, DNS777)))
#
#       FeedBack feature. Type in partyline .ourtube feedback [your email] <message>
#       to send the author any suggestion or comment. Insults are not welcome. (((? killed, DNS777)))
#
#       Added seacher, !youtube string and it will return matches
#       it is customizable (configure ourtube(outputsearch)) (((? killed, we have another !youtube trigger, DNS777)))
 
 
setudef flag ourtube
setudef flag ourtubecolors
 
global ourtube tcl_platform

# (1) Enable or (0) disable colors
set ourtube(colors) 1

# Flood Protection: after show a link, will ignore all links few seconds
# This means 1 link per 10 seconds.
set ourtube(rest) 10

# What language you can receive the youTube data? (if works heh)
set ourtube(lang) en

# This is the final output message what you will read in your channel.
#       -*- This is not for search command (only when someone pasted link)
# You can configure all fields that your eggdrop will show.
# <title>       will return the title of the video
# <author>      It was the author himself who had uploaded the video
# <views>       How many views the video has
# <rating>      His rating
# <description> Information by author - This may be disabled because it can
#               contain spam
# <comment>     Will show the last comment if exists - Same as description, take care
#               with spam.
# <uploaded>    Date of upload.
 
 
set ourtube(output) "\002YouTube Video\002: <title> | \002Views\002: <views> | \002Ratings\002: <rating> | \002Uploader\002:    <author>         | \002Uploaded\002: <uploaded> | \002Last comment\002: \0032<comment>\003"

# This is not required to edit, or yes.
 
set ourtube(author) "HackeMate (& DNS)"
set ourtube(name) "ourTube"
set ourtube(version) "1.0.2010"
set ourtube(package.http) [package require http]
set ourtube(protection) ""
if {$tcl_platform(os) eq "Linux"} {
    set platfrm "X11"
} else {
    set platfrm $tcl_platform(os)
}
http::config -useragent "Mozilla/5.0 ($platfrm; U; $tcl_platform(os) $tcl_platform(machine); $ourtube(lang); rv:1.9.0.3) ourTube 1.0" -accept "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
 
bind pubm - * otPub
 
proc otPub {nick uhost hand chan text} {
 
    if {![channel get $chan ourtube]} {
        return
    }
    global ourtube
    regsub -all -- {\017|\002|\037|\026|\003(\d{1,2})?(,\d{1,2})?} $text "" arg
 
    set webTarget [lsearch -inline [split $arg] {*http://*.youtube.*/watch?*}]
    if {([info exists ourtube(protection)]) && ([string is digit -strict $ourtube(protection)])} {
        set rest [expr [clock seconds]-$ourtube(protection)]
        if {$rest >= $ourtube(rest)} {
            set ourtube(protection) ""
        }
    } else {
        set ourtube(protection) ""
    }
    if {$webTarget ne ""} {
         if {! [regexp -nocase {^(http://)?([^/:]+)(:([0-9]+))?(/.*)?$} $webTarget]} {
            otLog log "Unsupported URL: $webTarget"
            return
        }
        if {$ourtube(protection) ne ""} {
            otLog "Resting... (flood protection) [duration [expr ([clock seconds]-$ourtube(protection))]] left"
            return
        }
        set ourtube(protection) [clock seconds]
        otLog log "Getting $webTarget ... from $nick on $chan"
        set data [otGet $webTarget]
        if {!$ourtube(colors)} {
            regsub -all -- {\017|\002|\037|\026|\003(\d{1,2})?(,\d{1,2})?} $data "" data
        }
        if {[string length $data] == 0} {
            set data "I was not able to reach Youtube's link. Probably I get a timeout. Try again."
        }
        otLog log "$data"
        putserv "PRIVMSG $chan :$data"
        utimer $ourtube(rest) [list set ourtube(protection) ""]
    }
}
 
proc otGet {web {relocation ""}} {
    global ourtube
    set token [http::geturl $web -timeout 4000]
    upvar #0 $token state
    set lastcode $state(http)
    set ncode ""
    regexp {[0-9]{3}} $lastcode ncode
    if {$ncode eq ""} {
        set ncode $lastcode
    }
    switch -- $ncode {
        "200" {
        }
        "302" {
            foreach {flag value} $state(meta) {
                if {$flag eq "Location"} {
                    # Due to invalid youtube link but valid url syntax we can
                    # receive an url forward. this handles that
                    http::cleanup $token
                    otLog log "$web forwards us to $value"
                    return [otGet $value "(Relocated)"]
                }
            }
        }
        "303" {
            otLog log "This video does not exists."
            http::cleanup $token
            return "That video does not exists. Server responded: $lastcode"
        }
        "404" {
            otLog log "$web - No such webpage."
            http::cleanup $token
            return "$web - No such webpage"
        }
        default {
            http::cleanup $token
            otLog log "unforeseen circumstances. Server responded: $lastcode"
            return "unforeseen circumstances. Server responded: $lastcode"
        }
    }
    set data [string map {"&quot\;" "\"" "&amp\;quot\;" "\"" "&amp;" "&"} $state(body)]
 
    http::cleanup $token
    set author ""
    set description ""
    set views ""
    set rating ""
    set uploaded ""
    #regexp {<title>(.*)</title>} $data "" title
    regexp {<meta name=\"title\" content=\"(.*?)\">.*} $data "" title
    regexp {class="hLink fn n contributor">(.*?)</a><br>} $data "" author
    regexp {<meta name=\"description\" content=\">(.*?)\">.*} $data "" description
    regexp {<div id=\"defaultRatingMessage\">(.*?)</span>.*} $data "" rating
    regexp {<span class=\"watch-video-added post-date\">(.*?)</span><br>} $data "" uploaded
    if {![regexp {<span id=\"watch-view-count\">(.*?)</span>} $data "" views]} { set views "no" }
    # This is not so smart way. I know, sorry about :)
    set comments ""
    set description ""
    regexp {<div id="recent_comments" class="comments">(.*?)<div id="div_comment_form_id} $data "" comments
    if {$comments ne ""} {
       regexp { rel="nofollow">(.*?)</a>} $comments "" user
       regexp {<span class="watch-comment-time">(.*?)</span>} $comments "" timeago
       regexp {<div class="watch-comment-body">(.*?)</div>} $comments "" comment
       set comment [string map {\n " " "<br>" ""} $comment]
       regsub -all -- {\<[^\>]*\>|\t} $comment "" comment
       regsub -all {\s+} $comment " " comment
       set comment "\<$user [string trim $timeago]\> [string trim $comment]"
    } else {
        set comment ""
    }
    regsub -all -- {\<[^\>]*\>|\t} $title "" title
    regsub -all -- {\<[^\>]*\>|\t} $description "" description
    regsub -all -- {\<[^\>]*\>|\t} $views "" views
    regsub -all -- {\<[^\>]*\>|\t} $rating "" rating
    set rating [lindex [split $rating] 0]
    set title [string map {"\n" " "} $title] 
    set title "$relocation $title"
    set title [string trim $title]
    if {![string is digit -strict $rating]} {
        set rating "no"
    }
    if {$comment eq ""} {
        set comment "This video doesn't have any comments until now"
    }
    if {$description eq ""} {
        set description "This video doesn't have any description"
    }
    set output [string map [list "<title>" $title "<author>" $author "<description>" $description "<views>" $views "<rating>" $rating "<uploaded>" $uploaded "<comment>" $comment] $ourtube(output)]
    return $output
}

# upvar #0 $token state
 
proc otLog {target string} {
    global ourtube
    if {![validchan $target]} {
        putlog "$ourtube(name)\: $string"
    } else {
        putserv "PRIVMSG $target :$ourtube(name)\: $string"
    }
}
 
otLog log "$ourtube(version) Loaded - by $ourtube(author)"
 
set ourtube(loaded) 1


Répondre Avertir
#10
Thx, je vais l'essayer ^^
Répondre Avertir
#11
Je remonte ce sujet un peu ancien car j'ai eu hier la demande d'avoir un script fonctionnel pour les urls normales et raccourcies de youtube (en youtu.be).

Après quelques efforts, voici ce que ça a donné:
tcl
package require http
bind PUBM - * mu
proc mu {nick uhost hand chan text} {
	set web(page) http://www.youtube.com
	set watch [regexp -nocase -- {\/watch\?v\=([^\s]{11})} $text youtubeid]
	if { $watch == 0 } {
		set watch [regexp -nocase -- {youtu\.be\/([^\s]{11})} $text a youtubeid]
		set youtubeid "/watch?v=$youtubeid"
	}
	set logoo "\002\00301,00You\00300,04Tube\002\017"
 
	if {$watch && $youtubeid != ""} {
		putlog "$web(page)$youtubeid"
		set agent "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1"     
		set t [::http::config -useragent $agent]
		set t [::http::geturl "$web(page)$youtubeid" -timeout 30000]
		set data [::http::data $t]
		::http::cleanup $t
 
		set l [regexp -all -inline -- {<meta name="title" content="(.*?)">.*?<span class="watch-view-count">.*?<strong>(.*?)</strong>} $data]
 
		regexp {"length_seconds": (\d+),} $data "" length
 
		foreach {black a b c d e} $l {
 
			set a [string map -nocase {\&\#39; \x27 &amp; \x26 &quot; \x22} $a]
			set b [string map [list \n ""] $b]
			set c [string map [list \n ""] $c]
			set d [string map [list \n ""] $d]
			set e [string map -nocase {\&\#39; \x27 &amp; \x26 &quot; \x22} $e]
 
			regsub -all {<.*?>} $a {} a
			regsub -all {<.*?>} $b {} b
			regsub -all {<.*?>} $c {} c
			regsub -all {<.*?>} $d {} d
			regsub -all {<.*?>} $e {} e			
 
			putserv "PRIVMSG $chan :$a' ( [duration $length] ) Viewed $b"
 
			    proc duration {s} {
				variable etube
				set hours [expr {$s / 3600}]
				set minutes [expr {($s / 60) % 60}]
				set seconds [expr {$s % 60}]
				set res ""
 
				if {$hours != 0} {append res "$hours hours"}				
				if {$minutes != 0} {append res " $minutes minutes"}
				if {$seconds != 0} {append res " $seconds seconds"}
				return $res
			}	
		}
	}
}
 
putlog "youtitle.tcl loaded..."



J'espère que cela en aidera certains.
Répondre
#12
Bonjour,

Donc j'ai télécharger le fichier Joint youtube.tcl
J'ai donc rehash/restart l'eggdrop pas de soucis.

Lorsque je mettais une url youtube voici ce que j'avais en PL :

Citation :[10:17:50] <Talk-Me> [10:18:39] Tcl error [mu]: can't read "youtubeid": no such variable
[10:18:05] <Talk-Me> [10:18:54] http://www.youtube.com/watch?v=A-nrSwUaA6o
[10:18:10] <Talk-Me> [10:18:59] Tcl error [mu]: can't read "youtubeid": no such variable
[10:18:12] <Talk-Me> [10:19:01] Tcl error [mu]: can't read "youtubeid": no such variable
[10:18:16] <Talk-Me> [10:19:05] Tcl error [mu]: can't read "youtubeid": no such variable

J'ai donc Modifier la ligne :

tcl
set youtubeid "/watch?v=$youtubeid"



Par celle ci :

tcl
set youtubeid {/watch?v=$youtubeid}



Et en remplaçant comme ça ya plus d'erreur en PL Wink
Répondre Avertir
#13
Bonjour,

je viens de tester ce script et voici le résultat :

[17:06] <Hitsu> http://www.youtube.com/watch?v=KY44zvhWhp4
[17:06] <VDMBot> Lil Wayne - Love Me (Explicit) ft. Drake, Future' ( 4 minutes 26 seconds ) Viewed Publiée le 14 févr. 2013

Il semblerait que le nombre de vues n'apparaisse pas...

Une idée ? J'ai regardé au niveau du $b mais je suis perdu...

Ah oui, et il semblerait que le script rajoute un ' à la fin de chaque titre cf " Future' "
Répondre Avertir
#14
thansk for post my script )))
(16/05/2012, 09:44)CrazyCat a écrit : Je remonte ce sujet un peu ancien car j'ai eu hier la demande d'avoir un script fonctionnel pour les urls normales et raccourcies de youtube (en youtu.be).

Après quelques efforts, voici ce que ça a donné:
tcl
package require http
bind PUBM - * mu
proc mu {nick uhost hand chan text} {
	set web(page) http://www.youtube.com
	set watch [regexp -nocase -- {\/watch\?v\=([^\s]{11})} $text youtubeid]
	if { $watch == 0 } {
		set watch [regexp -nocase -- {youtu\.be\/([^\s]{11})} $text a youtubeid]
		set youtubeid "/watch?v=$youtubeid"
	}
	set logoo "\002\00301,00You\00300,04Tube\002\017"
 
	if {$watch && $youtubeid != ""} {
		putlog "$web(page)$youtubeid"
		set agent "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1"     
		set t [::http::config -useragent $agent]
		set t [::http::geturl "$web(page)$youtubeid" -timeout 30000]
		set data [::http::data $t]
		::http::cleanup $t
 
		set l [regexp -all -inline -- {<meta name="title" content="(.*?)">.*?<span class="watch-view-count">.*?<strong>(.*?)</strong>} $data]
 
		regexp {"length_seconds": (\d+),} $data "" length
 
		foreach {black a b c d e} $l {
 
			set a [string map -nocase {\&\#39; \x27 &amp; \x26 &quot; \x22} $a]
			set b [string map [list \n ""] $b]
			set c [string map [list \n ""] $c]
			set d [string map [list \n ""] $d]
			set e [string map -nocase {\&\#39; \x27 &amp; \x26 &quot; \x22} $e]
 
			regsub -all {<.*?>} $a {} a
			regsub -all {<.*?>} $b {} b
			regsub -all {<.*?>} $c {} c
			regsub -all {<.*?>} $d {} d
			regsub -all {<.*?>} $e {} e			
 
			putserv "PRIVMSG $chan :$a' ( [duration $length] ) Viewed $b"
 
			    proc duration {s} {
				variable etube
				set hours [expr {$s / 3600}]
				set minutes [expr {($s / 60) % 60}]
				set seconds [expr {$s % 60}]
				set res ""
 
				if {$hours != 0} {append res "$hours hours"}				
				if {$minutes != 0} {append res " $minutes minutes"}
				if {$seconds != 0} {append res " $seconds seconds"}
				return $res
			}	
		}
	}
}
 
putlog "youtitle.tcl loaded..."



J'espère que cela en aidera certains.

SET
set l [regexp -all -inline -- {<meta name="title" content="(.*?)">.*?<span class="watch-view-count">.*?<strong>(.*?)</strong>} $data]
To

set l [regexp -all -inline -- {<title>(.*?)</title>.*?<span class="watch-view-count " >(.*?)</span>} $data]

4:06:34pm / * <iRoc> http://www.youtube.com/watch?v=NsmJ_l4jZFQ
4:06:36pm / * <iB0T> Tom Ford OWN Visionaires documentary - YouTube' ( 41 minutes 33 seconds ) Viewed 302.397


(27/03/2013, 18:10)Hitsu a écrit : Bonjour,

je viens de tester ce script et voici le résultat :

[17:06] <Hitsu> http://www.youtube.com/watch?v=KY44zvhWhp4
[17:06] <VDMBot> Lil Wayne - Love Me (Explicit) ft. Drake, Future' ( 4 minutes 26 seconds ) Viewed Publiée le 14 févr. 2013

Il semblerait que le nombre de vues n'apparaisse pas...

Une idée ? J'ai regardé au niveau du $b mais je suis perdu...

Ah oui, et il semblerait que le script rajoute un ' à la fin de chaque titre cf " Future' "
Répondre Avertir
#15
Bonsoir,

Pour ce qui et de ton problème concernant le ' à la fin de chaque titre je pense que cela viens d'ici :

tcl
putserv "PRIVMSG $chan :$a' ( [duration $length] ) Viewed $b"



Modifie ceci par :

tcl
putserv "PRIVMSG $chan :$a ( [duration $length] ) Viewed $b"



Après pour ce qui et du nombre de vues je ne voies pas dans le code TCL que c'est mis quelques part à moins que j'ai mal regardez mais je pense pas..
Faudrais se pencher sur le codes TCL pour voir comment faire ceci.
Répondre Avertir


Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)
Tchat 100% gratuit -Discutez en toute liberté