This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

YouTube Version 1.3 not working

Support & discussion of released scripts, and announcements of new releases.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

sputnik wrote:One more question (also stupid one): how do i bind it to ctcp action?

Code: Select all

bind ctcp -|- "ACTION" YouTube
doesn't do a thing...
Actually, it does do something. Just not the expected result.
Error: wrong # args: should be "YouTube nick host hand chan text"
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: Select all

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. :D
s
sputnik
Voice
Posts: 20
Joined: Wed Feb 23, 2011 1:16 pm

Post by sputnik »

Brilliant. That's exactly what i need. Thanks, speechless! :)
x
x0x
Op
Posts: 140
Joined: Tue Feb 10, 2009 6:42 am

Post by x0x »

Would it be possible to add number of views?
m
maurikouri
Voice
Posts: 1
Joined: Sat May 09, 2015 1:00 pm

Post by maurikouri »

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: Select all

# 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.
c
chepeme
Voice
Posts: 3
Joined: Fri Jul 11, 2014 7:35 am

Post by chepeme »

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
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.
More info on:
https://developers.google.com/youtube/v3/
a
arkadio
Voice
Posts: 6
Joined: Fri Dec 13, 2013 7:36 am

Post by arkadio »

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: Select all

{

    "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
            }
        }
    ]

}
V
Viper
Voice
Posts: 3
Joined: Fri Aug 29, 2014 4:59 am

Post by Viper »

not every script broke..

http://forum.egghelp.org/viewtopic.php?t=19777 (shameless plug :roll: )
wrote it a year ago and uses YouTube API V3, still working fine on my net :)
Post Reply