Changeset 22468
- Timestamp:
- 2010-07-21T16:31:05+12:00 (14 years ago)
- Location:
- gs2-extensions/music-ir/trunk/perllib/plugins
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/music-ir/trunk/perllib/plugins/MusicIRPlugin.pm
r22439 r22468 156 156 my $id3_artist = shift @$id3_artists || "Unkown"; 157 157 158 my $metadata_txt_filename = $self->retrieve_metadata($filename_full_path,$id3_title,$id3_artist); 158 my ($metadata_acexml_filename,$metadata_txt_filename) 159 = $self->retrieve_metadata($filename_full_path,$id3_title,$id3_artist); 160 161 if (-e $metadata_txt_filename) { 162 $self->parse_txt_metadata($doc_obj,$metadata_txt_filename); 163 } 164 165 159 166 } 160 167 -
gs2-extensions/music-ir/trunk/perllib/plugins/jSongMinerExtractor.pm
r22441 r22468 31 31 32 32 use Cwd; 33 use URI::Escape; 33 34 34 35 use strict; … … 77 78 } 78 79 80 sub urlEncode{ 81 # ARG 1: $to_encode is the string to URL encode 82 my ($to_encode) = @_; 83 return uri_escape($to_encode); 84 } 85 86 # URL Decode the given string 87 sub urlDecode{ 88 # ARG 1: $to_decode is the string to URL decode 89 my ($to_decode) = @_; 90 return uri_unescape($to_decode); 91 } 92 93 sub parse_txt_metadata 94 { 95 my $self = shift @_; 96 my ($doc_obj,$target_txt_file_path) = @_; 97 98 if (open(MIN,"<$target_txt_file_path")) { 99 100 my ($md_name, $md_value); 101 102 while (defined($md_name=<MIN>) && defined($md_value=<MIN>)) { 103 104 chomp $md_name; 105 chomp $md_value; 106 107 my $top_section=$doc_obj->get_top_section(); 108 109 $md_name =~ s/\+//g; 110 $md_value =~ s/\+//g; 111 112 $md_name = urlDecode($md_name); 113 $md_value = urlDecode($md_value); 114 115 # $md_name =~ s/\s+//g; 116 $md_name =~ s/\(.*?\)$//; 117 $md_name =~ s/Last\.FM/LastFM/g; 118 $md_name =~ s/:/^/g; 119 $md_name =~ s/(API)?\^/./; 120 121 $doc_obj->add_metadata($top_section,$md_name,$md_value); 122 } 123 124 close(MIN); 125 } 126 else { 127 print STDERR "Error: Failed to open $target_txt_file_path\n"; 128 print STDERR " !$\n"; 129 } 130 } 131 132 79 133 sub retrieve_metadata 80 134 { … … 91 145 $self->init_cache_for_file($source_file_path); 92 146 93 my $target_file_path; 147 my $target_txt_file_path; 148 my $target_acexml_file_path; 149 94 150 if ($self->{'enable_cache'}) { 95 151 my $cached_dir = $self->{'cached_dir'}; 96 152 my $file_root = $self->{'cached_file_root'}; 97 153 98 my $target_file = "${file_root}_metadata.txt"; 99 100 $target_file_path = &util::filename_cat($cached_dir,$target_file); 154 my $target_txt_file = "${file_root}_metadata.txt"; 155 my $target_acexml_file = "${file_root}.xml"; 156 157 $target_txt_file_path = &util::filename_cat($cached_dir,$target_txt_file); 158 $target_acexml_file_path = &util::filename_cat($cached_dir,$target_acexml_file); 101 159 } 102 160 else { 103 $target_file_path = &util::get_tmp_filename("_metadata.txt"); 161 $target_txt_file_path = &util::get_tmp_filename("_metadata.txt"); 162 $target_acexml_file_path = &util::get_tmp_filename(".xml"); 104 163 } 105 164 … … 119 178 $jsongminer_cmd .= " -title \"$id3_title\""; 120 179 $jsongminer_cmd .= " -artist \"$id3_artist\""; 121 $jsongminer_cmd .= " -file \"$source_file_path\""; 180 $jsongminer_cmd .= " -audio \"$source_file_path\""; 181 $jsongminer_cmd .= " -savefile \"$target_txt_file_path\""; 182 ## $jsongminer_cmd .= " -saveacefile \"$target_acexml_file_path\""; 122 183 123 184 if ($verbosity>2) { … … 127 188 128 189 my $print_info = { 'message_prefix' => "jSongMiner", 129 'message' => " Retrieving audio metadata for $source_file_no_path" };190 'message' => "jSongMinerExtractor: Retrieving audio metadata for $source_file_no_path" }; 130 191 131 192 my ($regenerated,$result,$had_error) 132 = $self->autorun_general_cmd($jsongminer_cmd,$source_file_path,$target_ file_path,$print_info);193 = $self->autorun_general_cmd($jsongminer_cmd,$source_file_path,$target_txt_file_path,$print_info); 133 194 134 195 if ($verbosity>2) { … … 143 204 chdir($store_cwd); 144 205 145 146 return ($target_file_path); 206 return ($target_acexml_file_path,$target_txt_file_path); 147 207 } 148 208
Note:
See TracChangeset
for help on using the changeset viewer.