root/plagger/trunk/lib/Plagger/Plugin/Filter/ConvertVideo.pm

Revision 113, 2.1 kB (checked in by anonymous, 2 years ago)

Change $enclosure->url argument.(RewriteEnclosureURL.pm)
Rewrite $enclosure->filename.(ConvertVideo.pm)

  • Property svn:executable set to *
Line 
1 package Plagger::Plugin::Filter::ConvertVideo;
2
3 use strict;
4 use base qw( Plagger::Plugin );
5 use Encode;
6 use File::Spec;
7
8 sub register {
9     my($self, $context) = @_;
10     $context->register_hook(
11         $self,
12         'update.entry.fixup' => \&filter,
13     );
14 }
15
16 sub filter {
17     my($self, $context, $args) = @_;
18
19     my $e = $args->{entry};
20
21     my $ext = $self->conf->{ext};
22
23     my $file = $e->enclosure->filename;
24     $file =~ s/\..*//;
25
26     my $output_file = File::Spec->catfile($self->conf->{output_dir}, "$file.$ext");
27     my $encode_type = $self->conf->{encode_type} || 0;
28
29     unless(-e $output_file){
30         my $tt = $context->template();
31         $tt->process("$encode_type.tt", {
32             %{$self->conf},
33             entry       => $e,
34             output_file => $output_file,
35         }, \my $commands) or $context->error($tt->error);
36
37         for (split '\n', $commands){
38             system($_);
39         }
40     }
41
42     $e->enclosure->local_path($output_file);
43     $e->enclosure->filename("$file.$ext");
44 }
45
46 1;
47 __END__
48
49 =head1 NAME
50
51 Plagger::Plugin::Filter::ConvertVideo - Get a video file of enclosure url and convert it.
52
53 =head1 SYNOPSIS
54
55   - module: Filter::ConvertVideo
56     config:
57       dir: K:\html\www.mizzy.org\cast
58       encode_type: 5
59       ext: m4v
60
61 =head1 DESCRIPTION
62
63 This plugin fetches video files of enclosure url, converts them into mpeg4 format, adds converted files to your iTunes and rewrites enclosure url.
64
65 This plugin requires 3GP Converter.
66 http://www.nurs.or.jp/~calcium/3gpp/
67
68 =head1 CONFIG
69
70 =head2 converter_dir
71
72 The directory name that 3GP Converter installed in.Default is C:\Program Files\AVCTest-051105.
73
74 =head2 dir
75
76 The directory name that converted files put in.
77
78 =head2 ext
79
80 The extension of converted video file.
81
82 =head2 encode type
83
84 Specify video encode type.It supports following encode type.
85
86 =over 6
87
88 =item 0 PSP/AVC QVGA/29.97fps/384kbps
89
90 =item 1 PSP/AVC QVGA/29.97fps/VBR QB25
91
92 =item 2 PSP/AVC QVGA/29.97fps/384kbps 2pass
93
94 =item 3 iPod/AVC QVGA(384kbps)
95
96 =item 4 iPod/AVC QVGA(600kbps)
97
98 =item 5 iPod/AVC QVGA(600kbps) 2pass
99
100 =back
101
102 =head1 AUTHOR
103
104 Gosuke Miyashita
105
106 =head1 SEE ALSO
107
108 L<Plagger>
109
110 =cut
111
Note: See TracBrowser for help on using the browser.