[SCM] Video extraction utility for YouTube, Google Video and other video sites (Debian packaging) branch, master, updated. upstream/2.1.9-120-g5cdb4a5
legatvs
legatvs at gmail.com
Thu Apr 9 07:25:57 UTC 2009
The following commit has been merged in the master branch:
commit 4abb64c519d67904a772f587748537784c01f267
Author: legatvs <legatvs at gmail.com>
Date: Thu Apr 2 13:26:34 2009 +0300
Improve content-type parsing for file suffix.
diff --git a/CHANGES b/CHANGES
index b44581c..de2e990 100644
--- a/CHANGES
+++ b/CHANGES
@@ -9,6 +9,10 @@ clive (2.1.10+).
* Add abby (front-end) compatibility
- Change output similar to cclive
- http://code.google.com/p/abby/
+ * Improve file suffix parsing from content-type
+ - Rewrite the content-type handling block in query_video_length
+ - Use whatever is found after slash in the content-type string
+ - Use "flv" for exceptions (e.g. octet-*, x-flv, etc.)
* Replace dashes in filenames (id, suffix) with underscores
* Youtube HD support (--format=mp4_hd)
- Thanks to bf for the patch
diff --git a/clive b/clive
index 39fd9b0..633eec7 100755
--- a/clive
+++ b/clive
@@ -410,48 +410,29 @@ sub query_video_length
if ($rc == 200)
{
- my $content_ok = 0;
- if ($content_type =~ m{video/(.*)})
+
+ # Figure out file suffix.
+ if ($content_type =~ /\/(.*)/)
{
- $entry{file_suffix} = $1;
- if ($content_type =~ /(.*)-(.*)$/)
+ if ( $1 =~ /octet/
+ || $1 =~ /x\-flv/
+ || $1 =~ /plain/)
{
- $entry{file_suffix} = $2;
- }
- $content_ok = 1;
- }
- # Evisor and Metacafe return "text/plain" for Content-Type
- elsif ($content_type =~ m{text/plain})
- {
- if ($opts{format} eq "flv")
+ # Use "flv" for these exceptions.
+ $entry{file_suffix} = "flv";
+ }
+ else
{
- if ( $entry{page_url} =~ /$re_hosts{IsEvisor}/
- or $entry{page_url} =~ /$re_hosts{IsCctv}/)
- {
- $entry{file_suffix} = "flv";
- $content_ok = 1;
- }
+
+ # Otherwise use whatever was found in content-type string.
+ $entry{file_suffix} = $1;
}
}
-
- # Liveleak and Break return "(flv-)application/octet-stream"
- elsif ($content_type =~ m{application/octet-stream})
+ else
{
- if ($opts{format} eq "flv")
- {
- if ( $entry{page_url} =~ /$re_hosts{IsBreak}/
- or $entry{page_url} =~ /$re_hosts{IsLiveleak}/)
- {
- $entry{file_suffix} = 'flv';
- $content_ok = 1;
- }
- }
+ $errmsg = "$content_type: unexpected content-type";
}
- $errmsg =
- "expected different content-type, "
- . "received \"$content_type\""
- unless $content_ok;
}
else
{
@@ -1717,7 +1698,7 @@ sub title_to_filename
my @a = strdomain($entry{page_url});
$entry{file_suffix} =~ s/\-/_/g;
- $entry{video_id} =~ s/\-/_/g;
+ $entry{video_id} =~ s/\-/_/g;
my %h = (
"%t" => $title,
--
Video extraction utility for YouTube, Google Video and other video sites (Debian packaging)
More information about the Pkg-perl-cvs-commits
mailing list