Created
September 19, 2011 00:14
-
-
Save lcapaldo/1225748 to your computer and use it in GitHub Desktop.
Irssi script for automatically queueing video links to VHX.tv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use Irssi; | |
use URI::Find::Rule; | |
use REST::Client; | |
use URI::Escape; | |
use vars qw($VERSION %IRSSI); | |
$VERSION = '0.01'; | |
%IRSSI = ( | |
authors => 'Logan Capaldo', | |
contact => '[email protected]', | |
name => 'VHX Enqueue', | |
description => 'Automatically queues video links to VHX.tv', | |
license => 'Public Domain' | |
); | |
sub note_url { | |
my ($channel, $data, $nick) = @_; | |
my @urls = URI::Find::Rule->scheme('http','https')->host(qr/youtube|vimeo/)->in($data); | |
if ( @urls ) { | |
my $user = Irssi::settings_get_str('vhxenq_user'); | |
my $apikey = Irssi::settings_get_str('vhxenq_apikey'); | |
my $client = REST::Client->new(host => 'http://api.vhx.tv/'); | |
for my $url_info ( @urls ) { | |
my $url = uri_escape($url_info->[1]); | |
$client->POST('/videos/queue.json', "login=$user&api_token=$apikey&url=$url\r\n", {}); | |
} | |
} | |
} | |
Irssi::settings_add_str('vhxenq', 'vhxenq_user', ''); | |
Irssi::settings_add_str('vhxeng', 'vhxenq_apikey', ''); | |
Irssi::signal_add_last('message public', \¬e_url); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment