Changeset 28549 for gs2-extensions


Ignore:
Timestamp:
2013-10-29T13:29:50+13:00 (10 years ago)
Author:
davidb
Message:

Added mapping for ID3v1 genre number to text-string

Location:
gs2-extensions/music-ir-src/trunk/perllib/plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gs2-extensions/music-ir-src/trunk/perllib/plugins/MusicIRPlugin.pm

    r26276 r28549  
    178178    }
    179179
     180    ### $self->check_for_existing_id3_genre($doc_obj);
     181
    180182    $doc_obj->associate_file($metadata_acexml_filename, "jsongminer.xml",
    181183                 "text/xml", $top_section);
  • gs2-extensions/music-ir-src/trunk/perllib/plugins/jSongMinerExtractor.pm

    r26276 r28549  
    9393}
    9494
     95sub map_id3v1_genre_num
     96{
     97    my ($genre_num) = @_;
     98
     99    $genre_num =~ s/(/\(/g;
     100    $genre_num =~ s/)/\)/g;
     101    $genre_num =~ s/^[\(\[\{](.*)[\)\]\}]$/$1/;
     102
     103    if (($genre_num =~ m/^\d+$/) && ($genre_num >= 148)) {
     104    return "Unknown";
     105    }
     106
     107    my $lookup_id3v1_genre = {
     108    "0"  => "Blues",
     109    "1"  => "Classic Rock",
     110    "2"  => "Country",
     111    "3"  => "Dance",
     112    "4"  => "Disco",
     113    "5"  => "Funk",
     114    "6"  => "Grunge",
     115    "7"  => "Hip-Hop",
     116    "8"  => "Jazz",
     117    "9"  => "Metal",
     118    "10" => "New Age",
     119    "11" => "Oldies",
     120    "12" => "Other",
     121    "13" => "Pop",
     122    "14" => "R&B",
     123    "15" => "Rap",
     124    "16" => "Reggae",
     125    "17" => "Rock",
     126    "18" => "Techno",
     127    "19" => "Industrial",
     128    "20" => "Alternative",
     129    "21" => "Ska",
     130    "22" => "Death Metal",
     131    "23" => "Pranks",
     132    "24" => "Soundtrack",
     133    "25" => "Euro-Techno",
     134    "26" => "Ambient",
     135    "27" => "Trip-Hop",
     136    "28" => "Vocal",
     137    "29" => "Jazz+Funk",
     138    "30" => "Fusion",
     139    "31" => "Trance",
     140    "32" => "Classical",
     141    "33" => "Instrumental",
     142    "34" => "Acid",
     143    "35" => "House",
     144    "36" => "Game",
     145    "37" => "Sound Clip",
     146    "38" => "Gospel",
     147    "39" => "Noise",
     148    "40" => "Alternative Rock",
     149    "41" => "Bass",
     150    "42" => "Soul",
     151    "43" => "Punk",
     152    "44" => "Space",
     153    "45" => "Meditative",
     154    "46" => "Instrumental Pop",
     155    "47" => "Instrumental Rock",
     156    "48" => "Ethnic",
     157    "49" => "Gothic",
     158    "50" => "Darkwave",
     159    "51" => "Techno-Industrial",
     160    "52" => "Electronic",
     161    "53" => "Pop-Folk",
     162    "54" => "Eurodance",
     163    "55" => "Dream",
     164    "56" => "Southern Rock",
     165    "57" => "Comedy",
     166    "58" => "Cult",
     167    "59" => "Gangsta",
     168    "60" => "Top 40",
     169    "61" => "Christian Rap",
     170    "62" => "Pop/Funk",
     171    "63" => "Jungle",
     172    "64" => "Native US",
     173    "65" => "Cabaret",
     174    "66" => "New Wave",
     175    "67" => "Psychadelic",
     176    "68" => "Rave",
     177    "69" => "Showtunes",
     178    "70" => "Trailer",
     179    "71" => "Lo-Fi",
     180    "72" => "Tribal",
     181    "73" => "Acid Punk",
     182    "74" => "Acid Jazz",
     183    "75" => "Polka",
     184    "76" => "Retro",
     185    "77" => "Musical",
     186    "78" => "Rock & Roll",
     187    "79" => "Hard Rock",
     188    "80" => "Folk",
     189    "81" => "Folk-Rock",
     190    "82" => "National Folk",
     191    "83" => "Swing",
     192    "84" => "Fast Fusion",
     193    "85" => "Bebob",
     194    "86" => "Latin",
     195    "87" => "Revival",
     196    "88" => "Celtic",
     197    "89" => "Bluegrass",
     198    "90" => "Avantgarde",
     199    "91" => "Gothic Rock",
     200    "92" => "Progressive Rock",
     201    "93" => "Psychedelic Rock",
     202    "94" => "Symphonic Rock",
     203    "95" => "Slow Rock",
     204    "96" => "Big Band",
     205    "97" => "Chorus",
     206    "98" => "Easy Listening",
     207    "99" => "Acoustic",
     208    "100" => "Humour",
     209    "101" => "Speech",
     210    "102" => "Chanson",
     211    "103" => "Opera",
     212    "104" => "Chamber Music",
     213    "105" => "Sonata",
     214    "106" => "Symphony",
     215    "107" => "Booty Bass",
     216    "108" => "Primus",
     217    "109" => "Porn Groove",
     218    "110" => "Satire",
     219    "111" => "Slow Jam",
     220    "112" => "Club",
     221    "113" => "Tango",
     222    "114" => "Samba",
     223    "115" => "Folklore",
     224    "116" => "Ballad",
     225    "117" => "Power Ballad",
     226    "118" => "Rhythmic Soul",
     227    "119" => "Freestyle",
     228    "120" => "Duet",
     229    "121" => "Punk Rock",
     230    "122" => "Drum Solo",
     231    "123" => "Acapella",
     232    "124" => "Euro-House",
     233    "125" => "Dance Hall",
     234    "126" => "Goa",
     235    "127" => "Drum & Bass",
     236    "128" => "Club - House",
     237    "129" => "Hardcore",
     238    "130" => "Terror",
     239    "131" => "Indie",
     240    "132" => "BritPop",
     241    "133" => "Negerpunk",
     242    "134" => "Polsk Punk",
     243    "135" => "Beat",
     244    "136" => "Christian Gangsta Rap",
     245    "137" => "Heavy Metal",
     246    "138" => "Black Metal",
     247    "139" => "Crossover",
     248    "140" => "Contemporary Christian",
     249    "141" => "Christian Rock",
     250    "142" => "Merengue",
     251    "143" => "Salsa",
     252    "144" => "Thrash Metal",
     253    "145" => "Anime",
     254    "146" => "JPop",
     255    "147" => "Synthpop"
     256    };
     257
     258    my $mapped_genre;
     259
     260    if (defined $lookup_id3v1_genre->{$genre_num}) {
     261    print STDERR "*** changing $genre_num -> ", $lookup_id3v1_genre->{$genre_num}, "\n";
     262    $mapped_genre = $lookup_id3v1_genre->{$genre_num};
     263    }
     264    else {
     265    $mapped_genre = $genre_num;
     266    }
     267
     268    return $mapped_genre;
     269}
     270
     271sub check_for_existing_id3_genre
     272{
     273    my $self = shift @_;
     274    my ($doc_obj) = @_;
     275
     276    my $top_section=$doc_obj->get_top_section();
     277
     278    # Look for ex.ID3.Genre as well, as special case
     279    my $genre_md_list = $doc_obj->get_metadata($top_section,"ex.ID3.Genre");
     280    my @new_genre_md_list = ();
     281   
     282    foreach my $gv (@$genre_md_list) {
     283    print STDERR "*** got match on ex.ID3.Genre -> '$gv'\n";
     284    my $new_gv = map_id3v1_genre_num($gv);
     285       
     286    push(@new_genre_md_list,$new_gv);
     287    }
     288   
     289    $doc_obj->delete_metadata($top_section,"ex.ID3.Genre");
     290    foreach my $gv (@new_genre_md_list) {
     291    $doc_obj->add_utf8_metadata($top_section,"ex.ID3.Genre",$gv);
     292    }
     293}
     294
     295
    95296sub parse_txt_metadata
    96297{
    97298    my $self = shift @_;
    98299    my ($doc_obj,$target_txt_file_path) = @_;
     300
     301    print STDERR "**#####** jSongMiner parsing txt metadata\n";
    99302
    100303    if (open(MIN,"<$target_txt_file_path")) {
     
    121324        $md_name =~ s/(API)?\^/./;
    122325
     326#       print STDERR "*** md_name = '$md_name'\n";
     327
     328        if ($md_name =~ m/genre$/i) {
     329        print STDERR "*** got match on $md_name -> $md_value\n";
     330        $md_value = map_id3v1_genre_num($md_value);
     331        }
     332
    123333        $doc_obj->add_utf8_metadata($top_section,$md_name,$md_value);
    124334    }
    125335
    126336    close(MIN);
     337
     338    $self->check_for_existing_id3_genre($doc_obj);
     339
    127340    }
    128341    else {
Note: See TracChangeset for help on using the changeset viewer.