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


PHP Misc::objectsIntoArray方法代码示例

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


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

示例1: getShowInfo

 /**
  * Main function for matching a releae searchname to a TvRage title
  * Returns basic show information array or -1 int if no match
  *
  * @param $showInfo
  *
  * @return array|int
  */
 public function getShowInfo($showInfo)
 {
     $matchedTitle = -1;
     $title = $showInfo['cleanname'];
     // Full search gives us the akas.
     $xml = Misc::getUrl(['url' => $this->xmlFullSearchUrl . urlencode(strtolower($title))]);
     if ($xml !== false) {
         $arrXml = @Misc::objectsIntoArray(simplexml_load_string($xml));
         // CheckXML Response is valid before processing
         if (isset($arrXml['show']) && is_array($arrXml)) {
             // We got exactly 1 match so lets convert it to an array so we can use it in the logic below.
             if (isset($arrXml['show']['showid'])) {
                 $newArr[] = $arrXml['show'];
                 unset($arrXml);
                 $arrXml['show'] = $newArr;
             }
             $highestPercent = 0;
             foreach ($arrXml['show'] as $show) {
                 if ($title == $show['name']) {
                     $matchedTitle = $show;
                     break;
                 }
                 // Get a match percentage based on our name and the name returned from tvr.
                 $matchPercent = $this->checkMatch($title, $show['name'], self::MATCH_PROBABILITY);
                 if ($matchPercent > $highestPercent) {
                     $matchedTitle = $show;
                     $highestPercent = $matchPercent;
                 }
                 // Check if there are any akas for this result and get a match percentage for them too.
                 if (isset($show['akas']['aka'])) {
                     if (is_array($show['akas']['aka'])) {
                         // Multiple akas.
                         foreach ($show['akas']['aka'] as $aka) {
                             $matchPercent = $this->checkMatch($title, $aka, self::MATCH_PROBABILITY);
                             if ($matchPercent > $highestPercent) {
                                 $matchedTitle = $show;
                                 $highestPercent = $matchPercent;
                             }
                         }
                     } else {
                         // One aka.
                         $matchPercent = $this->checkMatch($title, $show['akas']['aka'], self::MATCH_PROBABILITY);
                         if ($matchPercent > $highestPercent) {
                             $show['akas']['aka'][] = $show['akas']['aka'];
                             $matchedTitle = $show;
                             $highestPercent = $matchPercent;
                         }
                     }
                 }
             }
         } else {
             if ($this->echooutput) {
                 echo $this->pdo->log->primary('Nothing returned from tvrage.');
             }
         }
     }
     return $this->formatShowInfo($matchedTitle);
 }
开发者ID:zetas,项目名称:nZEDb,代码行数:66,代码来源:TvRage.php

示例2: _getAudioInfo

    /**
     * Fetch MediaInfo and a OGG sample for a Audio file.
     *
     * @param string $fileLocation
     * @param string $fileExtension
     *
     * @return bool
     */
    protected function _getAudioInfo($fileLocation, $fileExtension)
    {
        // Return values.
        $retVal = $audVal = false;
        // Check if audio sample fetching is on.
        if ($this->_processAudioSample === false) {
            $audVal = true;
        }
        // Check if media info fetching is on.
        if ($this->_processAudioInfo === false) {
            $retVal = true;
        }
        // Make sure the category is music or other.
        $rQuery = $this->pdo->queryOneRow(sprintf('SELECT searchname, categoryid AS id, group_id FROM releases WHERE proc_pp = 0 AND id = %d', $this->_release['id']));
        $musicParent = (string) Category::CAT_PARENT_MUSIC;
        if ($rQuery === false || !preg_match(sprintf('/%d\\d{3}|%d|%d|%d/', $musicParent[0], Category::CAT_MISC, Category::CAT_MOVIE_OTHER, Category::CAT_TV_OTHER), $rQuery['id'])) {
            return false;
        }
        if (is_file($fileLocation)) {
            // Check if media info is enabled.
            if ($retVal === false) {
                // Get the media info for the file.
                $xmlArray = Misc::runCmd($this->_killString . $this->pdo->getSetting('mediainfopath') . '" --Output=XML "' . $fileLocation . '"');
                if (is_array($xmlArray)) {
                    // Convert to array.
                    $arrXml = Misc::objectsIntoArray(@simplexml_load_string(implode("\n", $xmlArray)));
                    if (isset($arrXml['File']['track'])) {
                        foreach ($arrXml['File']['track'] as $track) {
                            if (isset($track['Album']) && isset($track['Performer'])) {
                                if (nZEDb_RENAME_MUSIC_MEDIAINFO && $this->_release['preid'] == 0) {
                                    // Make the extension upper case.
                                    $ext = strtoupper($fileExtension);
                                    // Form a new search name.
                                    if (!empty($track['Recorded_date']) && preg_match('/(?:19|20)\\d\\d/', $track['Recorded_date'], $Year)) {
                                        $newName = $track['Performer'] . ' - ' . $track['Album'] . ' (' . $Year[0] . ') ' . $ext;
                                    } else {
                                        $newName = $track['Performer'] . ' - ' . $track['Album'] . ' ' . $ext;
                                    }
                                    // Get the category or try to determine it.
                                    if ($ext === 'MP3') {
                                        $newCat = Category::CAT_MUSIC_MP3;
                                    } else {
                                        if ($ext === 'FLAC') {
                                            $newCat = Category::CAT_MUSIC_LOSSLESS;
                                        } else {
                                            $newCat = $this->_categorize->determineCategory($rQuery['group_id'], $newName);
                                        }
                                    }
                                    $newTitle = $this->pdo->escapeString(substr($newName, 0, 255));
                                    // Update the search name.
                                    $this->pdo->queryExec(sprintf('
											UPDATE releases
											SET searchname = %s, categoryid = %d, iscategorized = 1, isrenamed = 1, proc_pp = 1
											WHERE id = %d', $newTitle, $newCat, $this->_release['id']));
                                    $this->sphinx->updateRelease($this->_release['id'], $this->pdo);
                                    // Echo the changed name.
                                    if ($this->_echoCLI) {
                                        NameFixer::echoChangedReleaseName(['new_name' => $newName, 'old_name' => $rQuery['searchname'], 'new_category' => $newCat, 'old_category' => $rQuery['id'], 'group' => $rQuery['group_id'], 'release_id' => $this->_release['id'], 'method' => 'ProcessAdditional->_getAudioInfo']);
                                    }
                                }
                                // Add the media info.
                                $this->_releaseExtra->addFromXml($this->_release['id'], $xmlArray);
                                $retVal = true;
                                $this->_foundAudioInfo = true;
                                if ($this->_echoCLI) {
                                    $this->_echo('a', 'primaryOver', false);
                                }
                                break;
                            }
                        }
                    }
                }
            }
            // Check if creating audio samples is enabled.
            if ($audVal === false) {
                // File name to store audio file.
                $audioFileName = $this->_release['guid'] . '.ogg';
                // Create an audio sample.
                Misc::runCmd($this->_killString . $this->pdo->getSetting('ffmpegpath') . '" -t 30 -i "' . $fileLocation . '" -acodec libvorbis -loglevel quiet -y "' . $this->tmpPath . $audioFileName . '"');
                // Check if the new file was created.
                if (is_file($this->tmpPath . $audioFileName)) {
                    // Try to move the temp audio file.
                    $renamed = rename($this->tmpPath . $audioFileName, $this->_audioSavePath . $audioFileName);
                    if (!$renamed) {
                        // Try to copy it if it fails.
                        $copied = copy($this->tmpPath . $audioFileName, $this->_audioSavePath . $audioFileName);
                        // Delete the old file.
                        unlink($this->tmpPath . $audioFileName);
                        // If it didn't copy continue.
                        if (!$copied) {
                            return false;
                        }
//.........这里部分代码省略.........
开发者ID:kaibosh,项目名称:nZEDb,代码行数:101,代码来源:ProcessAdditional.php

示例3: addFromXml

 public function addFromXml($releaseID, $xml)
 {
     $xmlObj = @simplexml_load_string($xml);
     $arrXml = Misc::objectsIntoArray($xmlObj);
     $containerformat = '';
     $overallbitrate = '';
     if (isset($arrXml['File']) && isset($arrXml['File']['track'])) {
         foreach ($arrXml['File']['track'] as $track) {
             if (isset($track['@attributes']) && isset($track['@attributes']['type'])) {
                 if ($track['@attributes']['type'] == 'General') {
                     if (isset($track['Format'])) {
                         $containerformat = $track['Format'];
                     }
                     if (isset($track['Overall_bit_rate'])) {
                         $overallbitrate = $track['Overall_bit_rate'];
                     }
                 } else {
                     if ($track['@attributes']['type'] == 'Video') {
                         $videoduration = $videoformat = $videocodec = $videowidth = $videoheight = $videoaspect = $videoframerate = $videolibrary = '';
                         if (isset($track['Duration'])) {
                             $videoduration = $track['Duration'];
                         }
                         if (isset($track['Format'])) {
                             $videoformat = $track['Format'];
                         }
                         if (isset($track['Codec_ID'])) {
                             $videocodec = $track['Codec_ID'];
                         }
                         if (isset($track['Width'])) {
                             $videowidth = preg_replace('/[^0-9]/', '', $track['Width']);
                         }
                         if (isset($track['Height'])) {
                             $videoheight = preg_replace('/[^0-9]/', '', $track['Height']);
                         }
                         if (isset($track['Display_aspect_ratio'])) {
                             $videoaspect = $track['Display_aspect_ratio'];
                         }
                         if (isset($track['Frame_rate'])) {
                             $videoframerate = str_replace(' fps', '', $track['Frame_rate']);
                         }
                         if (isset($track['Writing_library'])) {
                             $videolibrary = $track['Writing_library'];
                         }
                         $this->addVideo($releaseID, $containerformat, $overallbitrate, $videoduration, $videoformat, $videocodec, $videowidth, $videoheight, $videoaspect, $videoframerate, $videolibrary);
                     } else {
                         if ($track['@attributes']['type'] == 'Audio') {
                             $audioID = 1;
                             $audioformat = $audiomode = $audiobitratemode = $audiobitrate = $audiochannels = $audiosamplerate = $audiolibrary = $audiolanguage = $audiotitle = '';
                             if (isset($track['@attributes']['streamid'])) {
                                 $audioID = $track['@attributes']['streamid'];
                             }
                             if (isset($track['Format'])) {
                                 $audioformat = $track['Format'];
                             }
                             if (isset($track['Mode'])) {
                                 $audiomode = $track['Mode'];
                             }
                             if (isset($track['Bit_rate_mode'])) {
                                 $audiobitratemode = $track['Bit_rate_mode'];
                             }
                             if (isset($track['Bit_rate'])) {
                                 $audiobitrate = $track['Bit_rate'];
                             }
                             if (isset($track['Channel_s_'])) {
                                 $audiochannels = $track['Channel_s_'];
                             }
                             if (isset($track['Sampling_rate'])) {
                                 $audiosamplerate = $track['Sampling_rate'];
                             }
                             if (isset($track['Writing_library'])) {
                                 $audiolibrary = $track['Writing_library'];
                             }
                             if (isset($track['Language'])) {
                                 $audiolanguage = $track['Language'];
                             }
                             if (isset($track['Title'])) {
                                 $audiotitle = $track['Title'];
                             }
                             $this->addAudio($releaseID, $audioID, $audioformat, $audiomode, $audiobitratemode, $audiobitrate, $audiochannels, $audiosamplerate, $audiolibrary, $audiolanguage, $audiotitle);
                         } else {
                             if ($track['@attributes']['type'] == 'Text') {
                                 $subsID = 1;
                                 $subslanguage = 'Unknown';
                                 if (isset($track['@attributes']['streamid'])) {
                                     $subsID = $track['@attributes']['streamid'];
                                 }
                                 if (isset($track['Language'])) {
                                     $subslanguage = $track['Language'];
                                 }
                                 $this->addSubs($releaseID, $subsID, $subslanguage);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:kaibosh,项目名称:nZEDb,代码行数:98,代码来源:ReleaseExtra.php

示例4: getRageMatch

 public function getRageMatch($showInfo)
 {
     $title = $showInfo['cleanname'];
     // Full search gives us the akas.
     $xml = Misc::getUrl(['url' => $this->xmlFullSearchUrl . urlencode(strtolower($title))]);
     if ($xml !== false) {
         $arrXml = @Misc::objectsIntoArray(simplexml_load_string($xml));
         if (isset($arrXml['show']) && is_array($arrXml)) {
             // We got a valid xml response
             $titleMatches = $urlMatches = $akaMatches = [];
             if (isset($arrXml['show']['showid'])) {
                 // We got exactly 1 match so lets convert it to an array so we can use it in the logic below.
                 $newArr = [];
                 $newArr[] = $arrXml['show'];
                 unset($arrXml);
                 $arrXml['show'] = $newArr;
             }
             foreach ($arrXml['show'] as $arr) {
                 $tvrlink = '';
                 // Get a match percentage based on our name and the name returned from tvr.
                 $titlepct = $this->checkMatch($title, $arr['name']);
                 if ($titlepct !== false) {
                     $titleMatches[$titlepct][] = ['title' => $arr['name'], 'showid' => $arr['showid'], 'country' => $this->countryCode($arr['country']), 'genres' => $arr['genres'], 'tvr' => $arr];
                 }
                 // Get a match percentage based on our name and the url returned from tvr.
                 if (isset($arr['link']) && preg_match('/tvrage\\.com\\/((?!shows)[^\\/]*)$/i', $arr['link'], $tvrlink)) {
                     $urltitle = str_replace('_', ' ', $tvrlink[1]);
                     $urlpct = $this->checkMatch($title, $urltitle);
                     if ($urlpct !== false) {
                         $urlMatches[$urlpct][] = ['title' => $urltitle, 'showid' => $arr['showid'], 'country' => $this->countryCode($arr['country']), 'genres' => $arr['genres'], 'tvr' => $arr];
                     }
                 }
                 // Check if there are any akas for this result and get a match percentage for them too.
                 if (isset($arr['akas']['aka'])) {
                     if (is_array($arr['akas']['aka'])) {
                         // Multuple akas.
                         foreach ($arr['akas']['aka'] as $aka) {
                             $akapct = $this->checkMatch($title, $aka);
                             if ($akapct !== false) {
                                 $akaMatches[$akapct][] = ['title' => $aka, 'showid' => $arr['showid'], 'country' => $this->countryCode($arr['country']), 'genres' => $arr['genres'], 'tvr' => $arr];
                             }
                         }
                     } else {
                         // One aka.
                         $akapct = $this->checkMatch($title, $arr['akas']['aka']);
                         if ($akapct !== false) {
                             $akaMatches[$akapct][] = ['title' => $arr['akas']['aka'], 'showid' => $arr['showid'], 'country' => $this->countryCode($arr['country']), 'genres' => $arr['genres'], 'tvr' => $arr];
                         }
                     }
                 }
             }
             // Reverse sort our matches so highest matches are first.
             krsort($titleMatches);
             krsort($urlMatches);
             krsort($akaMatches);
             // Look for 100% title matches first.
             if (isset($titleMatches[100])) {
                 if ($this->echooutput) {
                     echo $this->pdo->log->primary('Found 100% match: "' . $titleMatches[100][0]['title'] . '"');
                 }
                 return $titleMatches[100][0];
             }
             // Look for 100% url matches next.
             if (isset($urlMatches[100])) {
                 if ($this->echooutput) {
                     echo $this->pdo->log->primary('Found 100% url match: "' . $urlMatches[100][0]['title'] . '"');
                 }
                 return $urlMatches[100][0];
             }
             // Look for 100% aka matches next.
             if (isset($akaMatches[100])) {
                 if ($this->echooutput) {
                     echo $this->pdo->log->primary('Found 100% aka match: "' . $akaMatches[100][0]['title'] . '"');
                 }
                 return $akaMatches[100][0];
             }
             // No 100% matches, loop through what we got and if our next closest match is more than TvRage::MATCH_PROBABILITY % of the title lets take it.
             foreach ($titleMatches as $mk => $mv) {
                 // Since its not 100 match if we have country info lets use that to make sure we get the right show.
                 if (isset($showInfo['country']) && !empty($showInfo['country']) && !empty($mv[0]['country'])) {
                     if (strtolower($showInfo['country']) != strtolower($mv[0]['country'])) {
                         continue;
                     }
                 }
                 if ($this->echooutput) {
                     echo $this->pdo->log->primary('Found ' . $mk . '% match: "' . $titleMatches[$mk][0]['title'] . '"');
                 }
                 return $titleMatches[$mk][0];
             }
             // Same as above but for akas.
             foreach ($akaMatches as $ak => $av) {
                 if (isset($showInfo['country']) && !empty($showInfo['country']) && !empty($av[0]['country'])) {
                     if (strtolower($showInfo['country']) != strtolower($av[0]['country'])) {
                         continue;
                     }
                 }
                 if ($this->echooutput) {
                     echo $this->pdo->log->primary('Found ' . $ak . '% aka match: "' . $akaMatches[$ak][0]['title'] . '"');
                 }
                 return $akaMatches[$ak][0];
//.........这里部分代码省略.........
开发者ID:advhamstrong,项目名称:nZEDb,代码行数:101,代码来源:TvRage.php


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