当前位置: 首页>>代码示例>>PHP>>正文


PHP getid3_id3v1::LookupGenreName方法代码示例

本文整理汇总了PHP中getid3_id3v1::LookupGenreName方法的典型用法代码示例。如果您正苦于以下问题:PHP getid3_id3v1::LookupGenreName方法的具体用法?PHP getid3_id3v1::LookupGenreName怎么用?PHP getid3_id3v1::LookupGenreName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在getid3_id3v1的用法示例。


在下文中一共展示了getid3_id3v1::LookupGenreName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Analyze

 public function Analyze()
 {
     $getid3 = $this->getid3;
     fseek($getid3->fp, -256, SEEK_END);
     $pre_id3v1 = fread($getid3->fp, 128);
     $id3v1_tag = fread($getid3->fp, 128);
     if (substr($id3v1_tag, 0, 3) == 'TAG') {
         $getid3->info['avdataend'] -= 128;
         // Shortcut
         $getid3->info['id3v1'] = array();
         $info_id3v1 =& $getid3->info['id3v1'];
         $info_id3v1['title'] = getid3_id3v1::cutfield(substr($id3v1_tag, 3, 30));
         $info_id3v1['artist'] = getid3_id3v1::cutfield(substr($id3v1_tag, 33, 30));
         $info_id3v1['album'] = getid3_id3v1::cutfield(substr($id3v1_tag, 63, 30));
         $info_id3v1['year'] = getid3_id3v1::cutfield(substr($id3v1_tag, 93, 4));
         $info_id3v1['comment'] = substr($id3v1_tag, 97, 30);
         // can't remove nulls yet, track detection depends on them
         $info_id3v1['genreid'] = ord(substr($id3v1_tag, 127, 1));
         // If second-last byte of comment field is null and last byte of comment field is non-null then this is ID3v1.1 and the comment field is 28 bytes long and the 30th byte is the track number
         if ($id3v1_tag[125] === "" && $id3v1_tag[126] !== "") {
             $info_id3v1['track'] = ord(substr($info_id3v1['comment'], 29, 1));
             $info_id3v1['comment'] = substr($info_id3v1['comment'], 0, 28);
         }
         $info_id3v1['comment'] = getid3_id3v1::cutfield($info_id3v1['comment']);
         $info_id3v1['genre'] = getid3_id3v1::LookupGenreName($info_id3v1['genreid']);
         if (!empty($info_id3v1['genre'])) {
             unset($info_id3v1['genreid']);
         }
         if (empty($info_id3v1['genre']) || @$info_id3v1['genre'] == 'Unknown') {
             unset($info_id3v1['genre']);
         }
         foreach ($info_id3v1 as $key => $value) {
             $key != 'comments' and $info_id3v1['comments'][$key][0] = $value;
         }
         $info_id3v1['tag_offset_end'] = filesize($getid3->filename);
         $info_id3v1['tag_offset_start'] = $info_id3v1['tag_offset_end'] - 128;
     }
     if (substr($pre_id3v1, 0, 3) == 'TAG') {
         // The way iTunes handles tags is, well, brain-damaged.
         // It completely ignores v1 if ID3v2 is present.
         // This goes as far as adding a new v1 tag *even if there already is one*
         // A suspected double-ID3v1 tag has been detected, but it could be that the "TAG" identifier is a legitimate part of an APE or Lyrics3 tag
         if (substr($pre_id3v1, 96, 8) == 'APETAGEX') {
             // an APE tag footer was found before the last ID3v1, assume false "TAG" synch
         } elseif (substr($pre_id3v1, 119, 6) == 'LYRICS') {
             // a Lyrics3 tag footer was found before the last ID3v1, assume false "TAG" synch
         } else {
             // APE and Lyrics3 footers not found - assume double ID3v1
             $getid3->warning('Duplicate ID3v1 tag detected - this has been known to happen with iTunes.');
             $getid3->info['avdataend'] -= 128;
         }
     }
     return true;
 }
开发者ID:ryumaru,项目名称:ryuzinewriter,代码行数:54,代码来源:module.tag.id3v1.php

示例2: StandardiseID3v1GenreName

 function StandardiseID3v1GenreName($OriginalGenre)
 {
     if (($GenreID = getid3_id3v1::LookupGenreID($OriginalGenre)) !== false) {
         return getid3_id3v1::LookupGenreName($GenreID);
     }
     return $OriginalGenre;
 }
开发者ID:nan0desu,项目名称:xyntach,代码行数:7,代码来源:module.tag.id3v1.php

示例3: ParseID3v2GenreString

 function ParseID3v2GenreString($genrestring)
 {
     // Parse genres into arrays of genreName and genreID
     // ID3v2.2.x, ID3v2.3.x: '(21)' or '(4)Eurodisco' or '(51)(39)' or '(55)((I think...)'
     // ID3v2.4.x: '21' $00 'Eurodisco' $00
     $genrestring = trim($genrestring);
     $returnarray = array();
     if (strpos($genrestring, "") !== false) {
         $unprocessed = trim($genrestring);
         // trailing nulls will cause an infinite loop.
         $genrestring = '';
         while (strpos($unprocessed, "") !== false) {
             // convert null-seperated v2.4-format into v2.3 ()-seperated format
             $endpos = strpos($unprocessed, "");
             $genrestring .= '(' . substr($unprocessed, 0, $endpos) . ')';
             $unprocessed = substr($unprocessed, $endpos + 1);
         }
         unset($unprocessed);
     }
     if (getid3_id3v1::LookupGenreID($genrestring)) {
         $returnarray['genre'][] = $genrestring;
     } else {
         while (strpos($genrestring, '(') !== false) {
             $startpos = strpos($genrestring, '(');
             $endpos = strpos($genrestring, ')');
             if (substr($genrestring, $startpos + 1, 1) == '(') {
                 $genrestring = substr($genrestring, 0, $startpos) . substr($genrestring, $startpos + 1);
                 $endpos--;
             }
             $element = substr($genrestring, $startpos + 1, $endpos - ($startpos + 1));
             $genrestring = substr($genrestring, 0, $startpos) . substr($genrestring, $endpos + 1);
             if (getid3_id3v1::LookupGenreName($element)) {
                 // $element is a valid genre id/abbreviation
                 if (empty($returnarray['genre']) || !in_array(getid3_id3v1::LookupGenreName($element), $returnarray['genre'])) {
                     // avoid duplicate entires
                     $returnarray['genre'][] = getid3_id3v1::LookupGenreName($element);
                 }
             } else {
                 if (empty($returnarray['genre']) || !in_array($element, $returnarray['genre'])) {
                     // avoid duplicate entires
                     $returnarray['genre'][] = $element;
                 }
             }
         }
     }
     if ($genrestring) {
         if (empty($returnarray['genre']) || !in_array($genrestring, $returnarray['genre'])) {
             // avoid duplicate entires
             $returnarray['genre'][] = $genrestring;
         }
     }
     return $returnarray;
 }
开发者ID:scottatron,项目名称:opentape,代码行数:53,代码来源:module.tag.id3v2.php

示例4: ParseID3v2GenreString

 function ParseID3v2GenreString($genrestring)
 {
     // Parse genres into arrays of genreName and genreID
     // ID3v2.2.x, ID3v2.3.x: '(21)' or '(4)Eurodisco' or '(51)(39)' or '(55)((I think...)'
     // ID3v2.4.x: '21' $00 'Eurodisco' $00
     $clean_genres = array();
     if (strpos($genrestring, "") === false) {
         $genrestring = preg_replace('#\\(([0-9]{1,3})\\)#', '$1' . "", $genrestring);
     }
     $genre_elements = explode("", $genrestring);
     foreach ($genre_elements as $element) {
         $element = trim($element);
         if ($element) {
             if (preg_match('#^[0-9]{1,3}#', $element)) {
                 $clean_genres[] = getid3_id3v1::LookupGenreName($element);
             } else {
                 $clean_genres[] = str_replace('((', '(', $element);
             }
         }
     }
     return $clean_genres;
 }
开发者ID:hackersforcharity,项目名称:rachelpiOS,代码行数:22,代码来源:module.tag.id3v2.php

示例5: QuicktimeParseAtom


//.........这里部分代码省略.........
                         $atomoffset += $boxsize;
                         switch ($boxtype) {
                             case 'mean':
                             case 'name':
                                 $atom_structure[$boxtype] = substr($boxdata, 4);
                                 break;
                             case 'data':
                                 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($boxdata, 0, 1));
                                 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($boxdata, 1, 3));
                                 switch ($atom_structure['flags_raw']) {
                                     case 0:
                                         // data flag
                                     // data flag
                                     case 21:
                                         // tmpo/cpil flag
                                         switch ($atomname) {
                                             case 'cpil':
                                             case 'pcst':
                                             case 'pgap':
                                                 $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
                                                 break;
                                             case 'tmpo':
                                                 $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 2));
                                                 break;
                                             case 'disk':
                                             case 'trkn':
                                                 $num = getid3_lib::BigEndian2Int(substr($boxdata, 10, 2));
                                                 $num_total = getid3_lib::BigEndian2Int(substr($boxdata, 12, 2));
                                                 $atom_structure['data'] = empty($num) ? '' : $num;
                                                 $atom_structure['data'] .= empty($num_total) ? '' : '/' . $num_total;
                                                 break;
                                             case 'gnre':
                                                 $GenreID = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
                                                 $atom_structure['data'] = getid3_id3v1::LookupGenreName($GenreID - 1);
                                                 break;
                                             case 'rtng':
                                                 $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
                                                 $atom_structure['data'] = $this->QuicktimeContentRatingLookup($atom_structure[$atomname]);
                                                 break;
                                             case 'stik':
                                                 $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
                                                 $atom_structure['data'] = $this->QuicktimeSTIKLookup($atom_structure[$atomname]);
                                                 break;
                                             case 'sfID':
                                                 $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
                                                 $atom_structure['data'] = $this->QuicktimeStoreFrontCodeLookup($atom_structure[$atomname]);
                                                 break;
                                             case 'egid':
                                             case 'purl':
                                                 $atom_structure['data'] = substr($boxdata, 8);
                                                 break;
                                             default:
                                                 $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
                                         }
                                         break;
                                     case 1:
                                         // text flag
                                     // text flag
                                     case 13:
                                         // image flag
                                     // image flag
                                     default:
                                         $atom_structure['data'] = substr($boxdata, 8);
                                         if ($atomname == 'covr') {
                                             // not a foolproof check, but better than nothing
                                             if (preg_match('#^\\xFF\\xD8\\xFF#', $atom_structure['data'])) {
开发者ID:rauldobrota,项目名称:zenphoto,代码行数:67,代码来源:module.audio-video.quicktime.php

示例6: ParseID3v2GenreString

 public function ParseID3v2GenreString($genrestring)
 {
     // Parse genres into arrays of genreName and genreID
     // ID3v2.2.x, ID3v2.3.x: '(21)' or '(4)Eurodisco' or '(51)(39)' or '(55)((I think...)'
     // ID3v2.4.x: '21' $00 'Eurodisco' $00
     $clean_genres = array();
     if (strpos($genrestring, "") === false) {
         $genrestring = preg_replace('#\\(([0-9]{1,3})\\)#', '$1' . "", $genrestring);
     }
     // note: MusicBrainz Picard incorrectly stores plaintext genres separated by "/" when writing in ID3v2.3 mode, hack-fix here:
     // replace / with NULL, then replace back the two ID3v1 genres that legitimately have "/" as part of the single genre name
     $genrestring = str_replace('/', "", $genrestring);
     $genrestring = str_replace('Pop' . "" . 'Funk', 'Pop/Funk', $genrestring);
     $genrestring = str_replace('Rock' . "" . 'Rock', 'Folk/Rock', $genrestring);
     // some other taggers separate multiple genres with semicolon, e.g. "Heavy Metal;Thrash Metal;Metal"
     $genrestring = str_replace(';', "", $genrestring);
     $genre_elements = explode("", $genrestring);
     foreach ($genre_elements as $element) {
         $element = trim($element);
         if ($element) {
             if (preg_match('#^[0-9]{1,3}#', $element)) {
                 $clean_genres[] = getid3_id3v1::LookupGenreName($element);
             } else {
                 $clean_genres[] = str_replace('((', '(', $element);
             }
         }
     }
     return $clean_genres;
 }
开发者ID:Jax24135,项目名称:d740ftp,代码行数:29,代码来源:module.tag.id3v2.php

示例7: generate_tag

 protected function generate_tag()
 {
     $result = 'TAG';
     $result .= str_pad(trim(substr($this->title, 0, 30)), 30, "", STR_PAD_RIGHT);
     $result .= str_pad(trim(substr($this->artist, 0, 30)), 30, "", STR_PAD_RIGHT);
     $result .= str_pad(trim(substr($this->album, 0, 30)), 30, "", STR_PAD_RIGHT);
     $result .= str_pad(trim(substr($this->year, 0, 4)), 4, "", STR_PAD_LEFT);
     if (!empty($this->track) && $this->track > 0 && $this->track <= 255) {
         $result .= str_pad(trim(substr($this->comment, 0, 28)), 28, "", STR_PAD_RIGHT);
         $result .= "";
         $result .= chr($this->track);
     } else {
         $result .= str_pad(trim(substr($comment, 0, 30)), 30, "", STR_PAD_RIGHT);
     }
     // both genre and genre_id set
     if ($this->genre && $this->genre_id) {
         if ($this->genre != getid3_id3v1::LookupGenreName($this->genre_id)) {
             throw new getid3_exception('Genre and genre_id does not match. Unset one and the other will be determined automatically.');
         }
     } elseif ($this->genre) {
         $this->genre_id = getid3_id3v1::LookupGenreID($this->genre);
     } else {
         if ($this->genre_id < 0 || $this->genre_id > 147) {
             $this->genre_id = 255;
             // 'unknown' genre
         }
         $this->genre = getid3_id3v1::LookupGenreName($this->genre_id);
     }
     $result .= chr(intval($this->genre_id));
     return $result;
 }
开发者ID:peterlindkvist,项目名称:apache-player,代码行数:31,代码来源:write.id3v1.php

示例8: QuicktimeParseAtom


//.........这里部分代码省略.........
                     $boxdata = substr($atom_data, $atomoffset + 8, $boxsize - 8);
                     switch ($boxtype) {
                         case 'mean':
                         case 'name':
                             $atom_structure[$boxtype] = substr($boxdata, 4);
                             break;
                         case 'data':
                             $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($boxdata, 0, 1));
                             $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($boxdata, 1, 3));
                             switch ($atom_structure['flags_raw']) {
                                 case 0:
                                     // data flag
                                 // data flag
                                 case 21:
                                     // tmpo/cpil flag
                                     switch ($atomname) {
                                         case 'cpil':
                                         case 'pcst':
                                         case 'pgap':
                                             $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
                                             break;
                                         case 'tmpo':
                                             $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 2));
                                             break;
                                         case 'disk':
                                         case 'trkn':
                                             $num = getid3_lib::BigEndian2Int(substr($boxdata, 10, 2));
                                             $num_total = getid3_lib::BigEndian2Int(substr($boxdata, 12, 2));
                                             $atom_structure['data'] = empty($num) ? '' : $num;
                                             $atom_structure['data'] .= empty($num_total) ? '' : '/' . $num_total;
                                             break;
                                         case 'gnre':
                                             $GenreID = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
                                             $atom_structure['data'] = getid3_id3v1::LookupGenreName($GenreID - 1);
                                             break;
                                         case 'rtng':
                                             $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
                                             $atom_structure['data'] = $this->QuicktimeContentRatingLookup($atom_structure[$atomname]);
                                             break;
                                         case 'stik':
                                             $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
                                             $atom_structure['data'] = $this->QuicktimeSTIKLookup($atom_structure[$atomname]);
                                             break;
                                         case 'sfID':
                                             $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
                                             $atom_structure['data'] = $this->QuicktimeStoreFrontCodeLookup($atom_structure[$atomname]);
                                             break;
                                         case 'egid':
                                         case 'purl':
                                             $atom_structure['data'] = substr($boxdata, 8);
                                             break;
                                         default:
                                             $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
                                     }
                                     break;
                                 case 1:
                                     // text flag
                                 // text flag
                                 case 13:
                                     // image flag
                                 // image flag
                                 default:
                                     $atom_structure['data'] = substr($boxdata, 8);
                                     break;
                             }
                             break;
开发者ID:sahartak,项目名称:newsroyal,代码行数:67,代码来源:module.audio-video.quicktime.php

示例9: ParseID3v2GenreString

 public static function ParseID3v2GenreString($genre_string)
 {
     // Parse genres into arrays of genreName and genreID
     // ID3v2.2.x, ID3v2.3.x: '(21)' or '(4)Eurodisco' or '(51)(39)' or '(55)((I think...)'
     // ID3v2.4.x: '21' $00 'Eurodisco' $00
     $genre_string = trim($genre_string);
     $return_array = array();
     if (strpos($genre_string, "") !== false) {
         $unprocessed = trim($genre_string);
         // trailing nulls will cause an infinite loop.
         $genre_string = '';
         while (strpos($unprocessed, "") !== false) {
             // convert null-seperated v2.4-format into v2.3 ()-seperated format
             $end_pos = strpos($unprocessed, "");
             $genre_string .= '(' . substr($unprocessed, 0, $end_pos) . ')';
             $unprocessed = substr($unprocessed, $end_pos + 1);
         }
         unset($unprocessed);
     } elseif (preg_match('/^([0-9]+|CR|RX)$/i', $genre_string)) {
         // some tagging program (including some that use TagLib) fail to include null byte after numeric genre
         $genre_string = '(' . $genre_string . ')';
     }
     if (getid3_id3v1::LookupGenreID($genre_string)) {
         $return_array['genre'][] = $genre_string;
     } else {
         while (strpos($genre_string, '(') !== false) {
             $start_pos = strpos($genre_string, '(');
             $end_pos = strpos($genre_string, ')');
             if (substr($genre_string, $start_pos + 1, 1) == '(') {
                 $genre_string = substr($genre_string, 0, $start_pos) . substr($genre_string, $start_pos + 1);
                 $end_pos--;
             }
             $element = substr($genre_string, $start_pos + 1, $end_pos - ($start_pos + 1));
             $genre_string = substr($genre_string, 0, $start_pos) . substr($genre_string, $end_pos + 1);
             if (getid3_id3v1::LookupGenreName($element)) {
                 // $element is a valid genre id/abbreviation
                 if (empty($return_array['genre']) || !in_array(getid3_id3v1::LookupGenreName($element), $return_array['genre'])) {
                     // avoid duplicate entires
                     $return_array['genre'][] = getid3_id3v1::LookupGenreName($element);
                 }
             } else {
                 if (empty($return_array['genre']) || !in_array($element, $return_array['genre'])) {
                     // avoid duplicate entires
                     $return_array['genre'][] = $element;
                 }
             }
         }
     }
     if ($genre_string) {
         if (empty($return_array['genre']) || !in_array($genre_string, $return_array['genre'])) {
             // avoid duplicate entires
             $return_array['genre'][] = $genre_string;
         }
     }
     return $return_array;
 }
开发者ID:rabyunghwa,项目名称:sslscrobbler,代码行数:56,代码来源:module.tag.id3v2.php


注:本文中的getid3_id3v1::LookupGenreName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。