public function testNormalize() { $downloader = App::getDownloader(); $url = '.http://mp3.zing.vn/bai-hat/Minh-Yeu-Tu-Bao-Gio--Em-La-Ba-Noi-Cua-Anh-OST--Miu-Le/ZW7WFEIW.html?a'; $method = self::getAccessibleMethod('\\Pimusic\\Downloader', '_normalize'); $this->assertEquals('http-mp3-zing-vn-bai-hat-inh-eu-u-ao-io-m-a-a-oi-ua-nh-iu-e-7-html-a', $method->invoke($downloader, $url), "Normalize does not match"); }
public function __construct() { $this->_downloader = \App::getDownloader(); $this->_mopidy = \App::getMopidy(); $this->_parser = \App::getParser(); $this->_slack = \App::getSlack(); }
public function fetchPlaylist($url) { $foundItems = []; $downloader = \App::getDownloader(); $page = $downloader->getCacheContent($url, ['prefix' => '/html', 'suffix' => '.html', 'gzip' => 1]); $document = \phpQuery::newDocument($page); $matches = $document->find('.item_content a.name_song'); foreach ($matches as $item) { $href = pq($item)->attr('href'); $songItems = $this->fetchSong($href); if (count($songItems) > 0) { $foundItems[] = $songItems[0]; } } //\phpQuery::unloadDocuments(); return $foundItems; }
public function fetchPlaylist($url) { $foundItems = []; $downloader = \App::getDownloader(); $page = $downloader->getCacheContent($url, ['prefix' => '/html', 'suffix' => '.html', 'gzip' => 1]); $document = \phpQuery::newDocument($page); $matches = $document->find('.item-song a.fn-name'); foreach ($matches as $item) { $href = pq($item)->attr('href'); $songItems = $this->fetchSong($href); if (count($songItems) > 0) { $item = $songItems[0]; $foundItems[] = $item; \App::dispatchEvent('playlist_fetch_song', array('id' => count($foundItems), 'item' => $item)); } } //\phpQuery::unloadDocuments(); return $foundItems; }
public function fetchPlaylist($url) { $foundItems = []; $downloader = \App::getDownloader(); $page = $downloader->getContent($url); $document = \phpQuery::newDocument($page); $metaTitle = $document->find('meta[property="og:title"]'); \App::dispatchEvent('playlist_fetch', array('title' => $metaTitle->attr("content"))); $matches = $document->find('.list_song_in_album .item_content a.name_song'); foreach ($matches as $item) { $href = pq($item)->attr('href'); $songItems = $this->fetchSong($href); if (count($songItems) > 0) { $songItem = $songItems[0]; $foundItems[] = $songItem; \App::dispatchEvent('playlist_fetch_song', array('id' => count($foundItems), 'item' => $songItem)); } } //\phpQuery::unloadDocuments(); return $foundItems; }
private function getItem($page) { $foundItems = []; $downloader = \App::getDownloader(); $pattern = '\\<source\\>\\<\\!\\[CDATA\\[(.*)\\]\\]\\>\\<\\/source\\>'; preg_match("/{$pattern}/", $page, $matches); $url = trim($matches[1]); $pattern = '\\<title\\>\\<\\!\\[CDATA\\[(.*)\\]\\]\\>\\<\\/title\\>'; preg_match("/{$pattern}/", $page, $matches); $title = trim($matches[1]); $pattern = '\\<performer\\>\\<\\!\\[CDATA\\[(.*)\\]\\]\\>\\<\\/performer\\>'; preg_match("/{$pattern}/", $page, $matches); $artists = trim($matches[1]); if ($title != '' && $url != '') { echo "Found song: {$title}\n"; echo "Downloading media {$url}\n\n"; $path = $downloader->getCachePath($url, ['prefix' => '/media', 'suffix' => '.mp3']); $foundItems[] = ['title' => $title, 'artists' => $artists, 'url' => $url, 'path' => $path]; } return $foundItems; }