Original post (with edits to remove outdated instructions):
Recently I was looking for a simple youtube script, but of all the ones I found, I didn't really like any.. either they were too basic, not reliable or I just didn't like the code or how they got their data.. (ewww @ regex based parsers..)
So I took the simple script YoutubeTitle (the only JSON based one I had seen; regexes == maintenance nightmare) and thought I'd make some changes, add some more data fields and be done with it.. ended up doing a bit more. The final result is about 90% new code, so it's closer to an entirely new script then an update but oh well..
I mostly wrote this thing for myself, but figured I'd post it here in case someone else has a use for it..
Note that this is actually my first eggdrop script AND even my first try at writing anything in TCL so.. it might still have some minor issues. While I'm new to the language (TCL), I am not new to programming, so don't worry, it shouldn't cause explosions..
There's a couple more things I'd like to do at some point, mostly code improvements like putting everything in a namespace, but it works right now and I'll see about the rest later..
Highlights of this script:
The script should be self explanatory, but there are 3 items worth noting:* Use the YouTube Data API V3. (Requires TLS support!)
* Strip out flat_json_decoder and use json & dict packages instead.
* Many more data elements supported in response format (possible by new API).
* Added possiblity to turn the script on/off on a channel by channel basis.
* Added ability to search youtube and return the first result.
* Added support for YouTube searches returning multiple search results. (New in 2.1)
* Added basic anti-flood measures by implementing a minimum interval between searches. (New in 2.1)
1 - it requires TCL 8.5 and the http, json & tls packages to be installed.
2 - it uses the most recent version of the google API for accessing youtube data..
3 - there could be a conflict with other scripts that use TLS (eg: incith-google). These scripts create a handler for HTTPS - as does mine - but most don't seem to bother setting the source IP address to the my-ip setting from eggdrop.conf. Since the google API key can be linked to an IP, this may cause authentication issues.. the best solution is to ensure this script is loaded last so it will overwrite the HTTPS handler created by scripts loaded before it.
GIT repository: http://git.milanza.org/?p=eggdrop-scripts/YoutubeTitle
Direct download of 2.1 here