Changeset f6c9736 for gutenbach/debian


Ignore:
Timestamp:
Mar 1, 2009, 7:42:30 AM (16 years ago)
Author:
Geoffrey Thomas <geofft@…>
Branches:
master, debian, mac, no-cups, nodebathena, web
Children:
a19df84
Parents:
014f817
git-author:
Geoffrey Thomas <geofft@…> (03/01/09 07:42:30)
git-committer:
Geoffrey Thomas <geofft@…> (03/01/09 07:42:30)
Message:

Support YouTube? videos.

Requires youtube-dl to be installed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gutenbach/debian/lib/sipbmp3-filter

    r014f817 rf6c9736  
    2121use LWP::UserAgent;
    2222use Data::Dumper;
     23use IPC::Open2;
    2324
    2425my $zephyr_class = "sipb-auto";
     
    143144elsif ($opts{'C'} eq 'Z') {
    144145    $filepath = resolve_external_reference($filepath, \%opts);
    145     print STDERR "Resolved external reference to $filepath\n";
    146     printf(ZEPHYR "%s\n", $filepath);
    147     printf(STATUS "External: %s\n", $filepath);
     146    if ($filepath =~ m|http://www\.youtube\.com/watch\?v=|) {
     147        $pid = open2($out, $in, qw{youtube-dl -g2}, $filepath);
     148        $title = <$out>;
     149        print ZEPHYR "YouTube video $filepath\n$title";
     150        print STATUS "YouTube video $filepath\n$title";
     151        $filepath = <$out>;
     152        chomp $filepath;
     153        waitpid $pid, 0;
     154    } else {
     155        print STDERR "Resolved external reference to $filepath\n";
     156        printf(ZEPHYR "%s\n", $filepath);
     157        printf(STATUS "External: %s\n", $filepath);
     158    }
    148159}
    149160elsif (-T $filepath) {
     
    174185    if (<STDIN> =~ /^(\S+)/) {
    175186        $uri=$1;
     187
     188        if ($uri =~ m|http://www\.youtube\.com/watch\?v=|) {
     189            return $uri;
     190        }
    176191
    177192        my $response = $ua->head($uri);
Note: See TracChangeset for help on using the changeset viewer.