[PATCH 1/3] Fixed --tag-cnid implementation
dinkypumpkin
dinkypumpkin at gmail.com
Sun Oct 21 12:42:31 EDT 2012
The implementation of --tag-cnid relied on an iTunes hack that no longer
works. The implementation has been changed to generate 32-bit hashes
from PIDs to use as the catalogue ID (cnID atom) values. This should
prevent HD-SD combinations from being mismatched, but there is no
guarantee that the generate values won't conflict with values for media
purchased from the iTunes Store. Use with caution.
---
get_iplayer | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/get_iplayer b/get_iplayer
index 15029d5..1d0352c 100755
--- a/get_iplayer
+++ b/get_iplayer
@@ -9547,9 +9547,23 @@ sub tags_from_metadata {
$tags->{is_podcast} = $meta->{type} =~ /podcast/i || $opt->{tag_podcast}
|| ( $opt->{tag_podcast_radio} && ! $tags->{is_video} )
|| ( $opt->{tag_podcast_tv} && $tags->{is_video} );
+ $tags->{cnID} = $self->tag_cnid_from_pid($meta->{pid}) if $opt->{tag_cnid};
return $tags;
}
+# convert PID into 32-bit fake cnID
+sub tag_cnid_from_pid {
+ use integer;
+ my ($self, $pid) = @_;
+ my $cnid = 0;
+ foreach( split(//, $pid) ) {
+ $cnid = (unpack("L", (pack("L", 33 * $cnid))));
+ $cnid = (unpack("L", (pack "L", $cnid + ord($_))));
+ }
+ $cnid = (unpack("L", (pack "L", $cnid + ($cnid >> 5))));
+ return $cnid;
+}
+
# escape/enclose embedded quotes in command line parameters
sub tags_escape_quotes {
my ($tags) = @_;
@@ -9753,7 +9767,7 @@ sub tag_file_mp4 {
# video only
if ( $tags->{is_video} ) {
# all video
- push @cmd, ( '--cnID', 3004 ) if $opt->{tag_cnid};
+ push @cmd, ( '--cnID', $tags->{cnID} ) if $opt->{tag_cnid};
push @cmd, ( '--hdvideo', $tags->{hdvideo} ) if $opt->{tag_hdvideo};
# tv only
if ( $tags->{is_tvshow} ) {
--
1.7.10.2 (Apple Git-33)
More information about the get_iplayer
mailing list