| View previous topic :: View next topic |
| Author |
Message |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Fri May 31, 2013 4:46 am Post subject: |
|
|
| sputnik wrote: | One more question (also stupid one): how do i bind it to ctcp action? | Code: | | bind ctcp -|- "ACTION" YouTube | doesn't do a thing... |
Actually, it does do something. Just not the expected result.
| Quote: | | Error: wrong # args: should be "YouTube nick host hand chan text" |
| Quote: | bind ctcp <flags> <keyword> <proc>
proc-name <nick> <user@host> <handle> <dest> <keyword> <text> |
So you need to "wrap" ctcp action into the pub bind. This requires a "stub" procedure to facilitate handling the extra parameter before submitting the call to our standard pub bind. It would be as simple as adding this to the end of the script:
| Code: | bind ctcp - ACTION wrapYouTube
proc wrapYouTube {nick uhost hand dest keyword text} {
if {[string first # $dest] == 0} { YouTube $nick $uhost $hand $dest $text }
} |
Wallah, now it will work. Dance like an robot.  _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
sputnik Voice
Joined: 23 Feb 2011 Posts: 20
|
Posted: Sat Jun 01, 2013 10:59 am Post subject: |
|
|
Brilliant. That's exactly what i need. Thanks, speechless!  |
|
| Back to top |
|
 |
x0x Op
Joined: 10 Feb 2009 Posts: 140
|
Posted: Tue Dec 24, 2013 7:02 am Post subject: |
|
|
| Would it be possible to add number of views? |
|
| Back to top |
|
 |
maurikouri Voice
Joined: 09 May 2015 Posts: 1
|
Posted: Sat May 09, 2015 1:24 pm Post subject: |
|
|
Hi Guys!
Since Google changed code in youtube.com, it seems that this script (well, prolly any of youtube scripts) doesn't work.
The code itself looks like this:
| Code: | # YouTube (Eggdrop/Tcl), Version 1.3
#
# (c) creative (QuakeNet - #computerbase), 15. Feb. 2012
#
# This program is free software: you can redistribute it and / or modify it under the
# terms of the GNU General Public License, see http://www.gnu.org/licenses/gpl.html.
#
# Example:
# <bo2000> like her new video https://www.youtu.be/kfVsfOSbJY0
# <eggbert> [Y] Rebecca Black - Friday - Official Music Video, 17.09.2011 (O 1.8)
#
# Notice:
# !youtube (on|off) enables or disables script for active channel (flags "mno" only)
setudef flag youtube
bind pubm - *youtu.be/* YouTube
bind pubm - *youtube.com/watch*v=* YouTube
bind pub mno|mno !youtube YouTube-Settings
proc YouTube {nick host hand chan text} {
if {[channel get $chan youtube]} {
set y_api "http://gdata.youtube.com/feeds/api/videos/"
set y_odf "%d.%m.%Y"
if {[catch {package require http 2.5}]} {
putlog "YouTube: package http 2.5 or above required"
} else {
if {[regexp -nocase {(^|[ ]{1})(https{0,1}:\/\/(www\.){0,1}|www\.)(youtu\.be\/|youtube\.com\/watch[^ ]{1,}v=)([A-Za-z0-9_-]{11})} $text - - - - - y_vid]} {
if {[catch {set y_con [::http::geturl $y_api$y_vid -headers [list {GData-Version} {2}] -timeout 5000]}]} {
putlog "YouTube: connection error (e. g. host not found / reachable)"
} elseif {[::http::status $y_con] == "ok"} {
set y_data [::http::data $y_con]
catch {::http::cleanup $y_con}
} else {
putlog "YouTube: connection error (e. g. time out / no data received)"
catch {::http::cleanup $y_con}
}
}
}
}
if {[info exists y_data]} {
if {[regexp -nocase {<title>(.{1,})<\/title>} $y_data - y_data_t]} {
set y_data_t [string map -nocase [list {"} {"} {&} {&} {<} {<} {>} {>}] $y_data_t]
regsub -all -nocase {[ ]{1,}} $y_data_t { } y_data_t
} else {
putlog "YouTube: parsing error (<title>, $y_api$y_vid)"
}
if {[regexp -nocase {<published>([0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.000Z)<\/published>} $y_data - y_data_p]} {
set y_data_p [clock scan $y_data_p -format %Y-%m-%dT%H:%M:%S.000Z]
set y_data_p [clock format $y_data_p -format $y_odf]
} else {
putlog "YouTube: parsing error (<published>, $y_api$y_vid)"
}
if {[regexp -nocase {<gd:rating average='([0-9]{1}\.[0-9]{1,})'} $y_data - y_data_r]} {
set y_data_r [format %.1f $y_data_r]
set y_data_r "([encoding convertto utf-8 \u00D8] $y_data_r)"
} else {
set y_data_r "([encoding convertto utf-8 \u00D8] NR)"
}
if {[info exists y_data_t] && [info exists y_data_p] && [info exists y_data_r]} {
putserv "privmsg $chan :YouTube - $y_data_t, $y_data_p $y_data_r"
}
}
}
proc YouTube-Settings {nick host hand chan text} {
set status [channel get $chan youtube]
set mode [string tolower [lindex [split $text] 0]]
switch -- $mode {
"on" {
if {!$status} {
channel set $chan +youtube
puthelp "NOTICE $nick :YouTube: enabled for $chan"
putlog "YouTube script enabled (by $nick for $chan)"
} else {
puthelp "NOTICE $nick :YouTube is already enabled for $chan"
}
}
"off" {
if {$status} {
channel set $chan -youtube
puthelp "NOTICE $nick :YouTube disabled for $chan"
putlog "YouTube script disabled (by $nick for $chan)"
} else {
puthelp "NOTICE $nick :YouTube is already disabled for $chan"
}
}
default {
puthelp "notice $nick :YouTube: !youtube (on|off) enables or disables script for active channel"
}
}
} |
Since I don't know anything about coding (but I've got it working before) I'm here humble, asking you, if someone could point out how to fix it.
I'm running it with Windrop, if that matters.
Thank you. |
|
| Back to top |
|
 |
chepeme Voice
Joined: 11 Jul 2014 Posts: 3
|
Posted: Sat May 16, 2015 11:12 am Post subject: |
|
|
On the 20th april they closed the api 2.0 and now you have to use the api 3.0.
There is a partial solution, but did not work for me
| Quote: |
If you're a developer, change to eol.gdata.youtube.com from gdata.youtube.com to test the response of your app. You are given enough time to migrate your app until July 31, 2015. It is highly recommended now that you use Data API v3 instead to avoid further outages. You surely don't want to annoy your users so make sure you migrate your app ASAP.
|
With the new API you need a https connection and an api key to get the information.
| Quote: | | https://www.googleapis.com/youtube/v3/videos?id=Q3d-z2ZAOUY&part=snippet,contentDetails&key=YOURAPIKEY |
More info on:
https://developers.google.com/youtube/v3/ |
|
| Back to top |
|
 |
arkadio Voice
Joined: 13 Dec 2013 Posts: 6
|
Posted: Sat May 30, 2015 10:28 pm Post subject: |
|
|
the new api v3 returns a JSON, I guess every Youtube reader we have parses the html looking for tags like <title> and stuff using regex.. we have to develop a new one.
new youtube response looks like
| Code: |
{
"kind": "youtube#videoListResponse",
"etag": "\"xmg9xJZuZD438sF4hb-VcBBREXc/cDUaSwJLm4RnKEyDrv0iBFvbiuk\"",
"pageInfo":
{
"totalResults": 1,
"resultsPerPage": 1
},
"items":
[
{
"kind": "youtube#video",
"etag": "\"xmg9xJZuZD438sF4hb-VcBBREXc/5Fur2afXCuTti3EYLVqVxnKTLFo\"",
"id": "7tcv4D2-acQ",
"snippet":
{
"publishedAt": "2015-05-29T11:00:00.000Z",
"channelId": "UCdcemy56JtVTrsFIOoqvV8g",
"title": "SONG CHALLENGE: BREAKFAST",
"description": "Breakfast always sounds good to me, but especially today! Huge thanks to Chase and Bed Bath & Beyond for sending me these items and challenging me to make music with them. http://chase.com/freedom\n\nAn extended mix of \"Breakfast Samba\" is available exclusively on my Patreon - join us and get the best deal on all my new music! http://patreon.com/andrewhuang\n\nLet's be friends forever:\nYouTube http://youtube.com/andrewhuang\nTwitter http://twitter.com/andrewismusic\nFacebook http://facebook.com/andrewismusic\nTumblr http://andrewismusic.tumblr.com\nInstagram http://instagram.com/andrewismusic\nSoundCloud http://soundcloud.com/andrewismusic\n\nIf you're new here, my name is Andrew Huang and I'm a musician who works with many genres and many instruments - and I've also made music with many things that aren't instruments like balloons, pants, water, and meth lab equipment. Find out more about me or get in touch at http://andrewismusic.com\n\nYou can also stream and download the majority of my discography at http://andrewhuang.bandcamp.com or see my other videos at http://youtube.com/andrewhuang\n\nAnd you can get my merch through DFTBA! http://store.dftba.com/collections/andrew-huang\n\nThanks for watching today and a big hug to you if you share this video with someone!",
"thumbnails":
{
"default":
{
"url": "https://i.ytimg.com/vi/7tcv4D2-acQ/default.jpg",
"width": 120,
"height": 90
},
"medium":
{
"url": "https://i.ytimg.com/vi/7tcv4D2-acQ/mqdefault.jpg",
"width": 320,
"height": 180
},
"high":
{
"url": "https://i.ytimg.com/vi/7tcv4D2-acQ/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard":
{
"url": "https://i.ytimg.com/vi/7tcv4D2-acQ/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres":
{
"url": "https://i.ytimg.com/vi/7tcv4D2-acQ/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "ANDREW HUANG",
"categoryId": "10",
"liveBroadcastContent": "none",
"localized":
{
"title": "SONG CHALLENGE: BREAKFAST",
"description": "Breakfast always sounds good to me, but especially today! Huge thanks to Chase and Bed Bath & Beyond for sending me these items and challenging me to make music with them. http://chase.com/freedom\n\nAn extended mix of \"Breakfast Samba\" is available exclusively on my Patreon - join us and get the best deal on all my new music! http://patreon.com/andrewhuang\n\nLet's be friends forever:\nYouTube http://youtube.com/andrewhuang\nTwitter http://twitter.com/andrewismusic\nFacebook http://facebook.com/andrewismusic\nTumblr http://andrewismusic.tumblr.com\nInstagram http://instagram.com/andrewismusic\nSoundCloud http://soundcloud.com/andrewismusic\n\nIf you're new here, my name is Andrew Huang and I'm a musician who works with many genres and many instruments - and I've also made music with many things that aren't instruments like balloons, pants, water, and meth lab equipment. Find out more about me or get in touch at http://andrewismusic.com\n\nYou can also stream and download the majority of my discography at http://andrewhuang.bandcamp.com or see my other videos at http://youtube.com/andrewhuang\n\nAnd you can get my merch through DFTBA! http://store.dftba.com/collections/andrew-huang\n\nThanks for watching today and a big hug to you if you share this video with someone!"
},
"defaultAudioLanguage": "en"
},
"contentDetails":
{
"duration": "PT52S",
"dimension": "2d",
"definition": "hd",
"caption": "false",
"licensedContent": true
}
}
]
}
|
|
|
| Back to top |
|
 |
Viper Voice
Joined: 29 Aug 2014 Posts: 3
|
|
| Back to top |
|
 |
|
|
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
|
|