Skip to content

Instantly share code, notes, and snippets.

@lcapaldo
Created September 19, 2011 00:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lcapaldo/1225748 to your computer and use it in GitHub Desktop.
Save lcapaldo/1225748 to your computer and use it in GitHub Desktop.
Irssi script for automatically queueing video links to VHX.tv
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 => 'logancapaldo@gmail.com',
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', \&note_url);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment