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


PHP Artist::getIdsByString方法代码示例

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


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

示例1: run

 public function run()
 {
     // first of all - try to guess if this dir should be
     // treated as an album or as a bunch of loose tracks
     // further this method is adding score to several attributes which will be migrated to production db-table
     $this->setHandleAsAlbum();
     #print_r($this->r);
     cliLog("handleAsAlbumScore " . $this->handleAsAlbumScore, 3, 'purple');
     #die();
     #if($this->tracks[0]['relativePath'] == 'newroot/crse002cd--Calibre-Musique_Concrete-2CD-CRSE002CD-2001-sour/101-calibre-deep_everytime.mp3') {
     #print_r($this->r); die();
     #}
     // extract some attributes from tracks
     // those will be used for album stuff
     $mergedFromTracks = array('artist' => array(), 'genre' => array(), 'label' => array(), 'catalogNr' => array());
     foreach (array_keys($mergedFromTracks) as $what) {
         foreach ($this->tracks as $idx => $rawTagData) {
             $mergedFromTracks[$what][] = $this->getMostScored($idx, $what);
         }
         $mergedFromTracks[$what][] = $this->getMostScored('album', $what);
         $mergedFromTracks[$what] = join(',', array_unique($mergedFromTracks[$what]));
     }
     $albumArtists = count(trimExplode(",", $mergedFromTracks['artist'])) > 3 ? 'Various Artists' : $mergedFromTracks['artist'];
     $a = new Album();
     $a->setArtistId(join(",", Artist::getIdsByString($albumArtists)));
     $a->setGenreId(join(",", Genre::getIdsByString($mergedFromTracks['genre'])));
     #$a->setLabelId(join(",", Label::getIdsByString($mergedFromTracks['label'])));
     $a->setCatalogNr($this->mostScored['album']['catalogNr']);
     $a->setRelativePath($this->getRelativeDirectoryPath());
     $a->setRelativePathHash($this->getRelativeDirectoryPathHash());
     $a->setAdded($this->getDirectoryMtime());
     $a->setFilemtime($this->getDirectoryMtime());
     $a->setTitle($this->mostScored['album']['title']);
     $a->setYear($this->mostScored['album']['year']);
     $a->setIsJumble($this->handleAsAlbum === TRUE ? 0 : 1);
     $a->setTrackCount(count($this->tracks));
     #print_r($a); die();
     $a->update();
     $albumId = $a->getId();
     // add the whole bunch of valid and indvalid attributes to albumindex table
     $this->updateAlbumIndex($albumId);
     foreach ($this->tracks as $idx => $rawTagData) {
         $t = $this->migrateNonGuessableData($rawTagData);
         $t->setArtistId($this->mostScored[$idx]['artist']);
         // currently the string insted of an artistId
         $t->setTitle($this->mostScored[$idx]['title']);
         $t->setFeaturedArtistsAndRemixers();
         # setFeaturedArtistsAndRemixers() is processing:
         # $t->setArtistId();
         # $t->setFeaturingId();
         # $t->setRemixerId();
         $t->setGenreId(join(",", Genre::getIdsByString($this->getMostScored($idx, 'genre'))));
         $t->setLabelId(join(",", Label::getIdsByString($this->getMostScored($idx, 'label'))));
         $t->setCatalogNr($this->mostScored[$idx]['catalogNr']);
         $t->setDisc($this->mostScored[$idx]['disc']);
         $t->setNumber($this->mostScored[$idx]['number']);
         $t->setComment($this->mostScored[$idx]['comment']);
         $t->setYear($this->mostScored[$idx]['year']);
         $t->setAlbumId($albumId);
         // make sure to use identical ids in table:rawtagdata and table:track
         \Slimpd\Track::ensureRecordIdExists($t->getId());
         $t->update();
         // make sure extracted images will be referenced to an album
         \Slimpd\Bitmap::addAlbumIdToTrackId($t->getId(), $albumId);
         #
         // add the whole bunch of valid and indvalid attributes to trackindex table
         $this->updateTrackIndex($t->getId(), $idx);
     }
     unset($this->r['album']);
     if ($this->handleAsAlbum === TRUE) {
         // try to guess if all tracks of this album has obviously invalid fixable attributes
     }
     return;
     print_r($this->r);
     #die();
 }
开发者ID:daskleinesys,项目名称:slimpd,代码行数:76,代码来源:main.php

示例2: setFeaturedArtistsAndRemixers


//.........这里部分代码省略.........
         }
     }
     // parse TITLE string for featured artists REGEX 2
     if (preg_match("/(.*)" . $groupFeat2 . "([^\\(]*)(.*)\$/i", $titleString, $m)) {
         #print_r($m); die();
         $sFeat = trim($m[4]);
         if (substr($sFeat, -1) == ')') {
             $sFeat = substr($sFeat, 0, -1);
         }
         if (isset($artistBlacklist[strtolower($sFeat)]) === FALSE) {
             $titleString = str_replace($m[2] . $m[3] . $m[4], " ", $titleString);
             $featuredArtists = array_merge($featuredArtists, preg_split($regexArtist, $sFeat));
         }
     }
     // parse title string for remixer regex 1
     if (preg_match($regexRemix, $titleString, $m)) {
         $remixerArtists = array_merge($remixerArtists, preg_split($regexArtist, $m[2]));
     }
     // parse title string for remixer regex 1
     if (preg_match($regexRemix2, $titleString, $m)) {
         #print_r($m); die();
         $remixerArtists = array_merge($remixerArtists, preg_split($regexArtist, $m[3]));
     }
     // clean up extracted remixer-names with common strings
     $tmp = array();
     foreach ($remixerArtists as $remixerArtist) {
         if (isset($artistBlacklist[strtolower($remixerArtist)]) === TRUE) {
             continue;
         }
         $tmp[] = str_ireplace($artistBlacklist, "", $remixerArtist);
     }
     $remixerArtists = $tmp;
     // clean up extracted featuring-names with common strings
     $tmp = array();
     foreach ($featuredArtists as $featuredArtist) {
         if (isset($artistBlacklist[strtolower($featuredArtist)]) === TRUE) {
             continue;
         }
         $tmp[] = str_ireplace($artistBlacklist, "", $featuredArtist);
     }
     $featuredArtists = $tmp;
     $regularArtists = array_unique(array_filter($regularArtists));
     $featuredArtists = array_unique($featuredArtists);
     $remixerArtists = array_unique($remixerArtists);
     // to avoid incomplete substitution caused by partly artistname-matches sort array by length DESC
     $allArtists = array_merge($regularArtists, $featuredArtists, $remixerArtists);
     usort($allArtists, 'sortHelper');
     $titlePattern = str_ireplace($allArtists, "%s", $titleString);
     // remove possible brackets from featuredArtists
     #$tmp = array();
     #foreach($featuredArtists as $featuredArtist) {
     #	$tmp[] = str_replace(array("(", ")"), "", $featuredArtist);
     #}
     #$featuredArtists = $tmp;
     if (substr_count($titlePattern, "%s") !== count($remixerArtists)) {
         // oh no - we have a problem
         // reset extracted remixers
         $titlePattern = $titleString;
         $remixerArtists = array();
     }
     /* TODO: do we need this?
     		// remove " (" from titlepattern in case that are the last 2 chars
     		if(preg_match("/(.*)\ \($/", $titlePattern, $m)) {
     			$titlePattern = $m[1];
     		}
     		*/
     // clean up artist names
     // unfortunately there are artist names like "45 Thieves"
     $regularArtists = $this->removeLeadingNumbers($regularArtists);
     $featuredArtists = $this->removeLeadingNumbers($featuredArtists);
     $remixerArtists = $this->removeLeadingNumbers($remixerArtists);
     $this->setArtistId(join(",", Artist::getIdsByString(join(" & ", $regularArtists))));
     if (count($featuredArtists) > 0) {
         $this->setFeaturingId(join(",", Artist::getIdsByString(join(" & ", $featuredArtists))));
     } else {
         # TODO: currently empty values are ignored in AbstractModel::update()
         # this is relevant for old exisiting database-items which already have an invalid featuringId-value
         $this->setFeaturingId('');
     }
     if (count($remixerArtists) > 0) {
         $this->setRemixerId(join(",", Artist::getIdsByString(join(" & ", $remixerArtists))));
     } else {
         # TODO: currently empty values are ignored in AbstractModel::update()
         # this is relevant for old exisiting database-items which already have an invalid remixerId-value
         $this->setRemixerId('');
     }
     // replace multiple whitespace with a single whitespace
     $titlePattern = preg_replace('!\\s+!', ' ', $titlePattern);
     // remove whitespace before bracket
     $titlePattern = str_replace(' )', ')', $titlePattern);
     $this->setTitle($titlePattern);
     return;
     echo "inputArtist: " . $inputArtistString . "\n";
     echo "inputTitle: " . $inputTitleString . "\n";
     echo "regular: " . print_r($regularArtists, 1);
     echo "feat: " . print_r($featuredArtists, 1);
     echo "remixer: " . print_r($remixerArtists, 1);
     echo "titlePattern: " . $titlePattern . "\n";
     die;
 }
开发者ID:daskleinesys,项目名称:slimpd,代码行数:101,代码来源:Track.php


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