示例#1
0
 public function getWantlist($username)
 {
     $this->cacheKey = 'Discogs_WantList_' . md5($username);
     $cachedResult = $this->getCache();
     if ($this->isCacheExpired() === false && $cachedResult !== false) {
         return $this->prepareQueries($cachedResult);
     }
     $this->wants = array();
     $wants = $this->search('users/' . $username . '/wants');
     // If no wants, message and leave
     if (!isset($wants->wants)) {
         parent::printLog("  - Your wantlist wasn't found");
         parent::printLog('  - Status Code: ' . $this->status);
         parent::printLog('  - Error: ' . $this->error);
         exit;
     }
     $this->theFormat($wants);
     // get total pages
     $pages = 1;
     if (isset($wants->pagination->pages)) {
         $pages = $wants->pagination->pages;
     }
     // If more than one page, get the rest
     if ($pages > 1) {
         for ($page = 2; $page <= $pages; $page++) {
             $this->theFormat($this->search('users/' . $username . '/wants', array('page' => $page)));
         }
     }
     $this->setCache($this->wants);
     return $this->prepareQueries();
 }
示例#2
0
 private function setEmail()
 {
     parent::printLog(' - Formatting email');
     if (empty($this->releases)) {
         return;
     }
     // Loop thru the listings and get the email ready
     foreach ($this->releases as $info) {
         $soldOut = $info['soldOut'] === true ? 'Yes' : 'No';
         $this->message .= '<img src="' . $info['image'] . '" style="display:inline;width:150px;height:150px;float:left;margin-right: 5px;margin-bottom:10px;margin-top:50px;" />';
         $this->message .= '<h2 style="margin-top: 60px;"><a href="' . $info['url'] . '">' . $info['title'] . '</a></h2>';
         $this->message .= '<table style="width:100%;border: 1px solid black;border-collapse: collapse;"><tr>';
         $this->message .= '<th style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">Price</th>';
         $this->message .= '<th style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">Old Price</th>';
         $this->message .= '<th style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">Price Difference</th>';
         $this->message .= '<th style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">Sold Out</th>';
         $this->message .= '<th style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">Changes</th></tr>';
         $this->message .= '<tr>';
         $this->message .= '<td style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">$' . $info['price'] . '</td>';
         $this->message .= '<td style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">$' . $info['oldPrice'] . '</td>';
         $this->message .= '<td style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">' . $info['priceChange'] . '</td>';
         $this->message .= '<td style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">' . $soldOut . '</td>';
         $this->message .= '<td style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">' . $info['changes'] . '</td>';
         $this->message .= '</tr>';
         $this->message .= '</table>';
     }
 }
示例#3
0
// Require some files
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/lib/vendor/autoload.php';
// Start the log
\VinylFinder\Base::printLog(date('Y-m-d H:i:s A'));
\VinylFinder\Base::printLog(' - Getting wantlist from discogs');
// Get your discogs wantlist
$discogs = new \VinylFinder\Discogs(DISCOGS_PERSONAL_TOKEN);
$wantList = $discogs->getWantList(DISCOGS_USERNAME);
$wantListTotal = count($wantList);
\VinylFinder\Base::printLog(' - ' . $wantListTotal . ' wantlist item(s) found');
// get 10% of the wantlist if debug is on
if (DEBUG === true) {
    $x = 0;
    $tenPercent = floor($wantListTotal * 0.1);
    $new = array();
    foreach ($wantList as $key => $array) {
        if ($x >= $tenPercent) {
            break;
        }
        $new[$key] = $wantList[$key];
        $x += 1;
    }
    unset($wantList);
    $wantList = $new;
    unset($new);
}
\VinylFinder\Base::printLog(' - Starting to search ebay for your wantlist');
// Ebay it
$ebay = new \VinylFinder\Ebay(EBAY_APPID);
$ebay->getListings($wantList);
示例#4
0
<?php

// Require some files
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/lib/vendor/autoload.php';
// Start the log
\VinylFinder\Base::printLog(date('Y-m-d H:i:s A'));
\VinylFinder\Base::printLog(' - Extracting pages from Mello Music');
$mmg = new \VinylFinder\MelloMusicGroup();
$mmg->getReleases();
示例#5
0
<?php

// Require some files
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/lib/vendor/autoload.php';
// Start the log
\VinylFinder\Base::printLog(date('Y-m-d H:i:s A'));
\VinylFinder\Base::printLog(' - Extracting pages from Bandcamp');
$bc = new \VinylFinder\Bandcamp();
$bc->getReleases();
示例#6
0
 private function setEmail()
 {
     parent::printLog(' - Formatting email');
     if (empty($this->wantList)) {
         return;
     }
     // Loop thru the listings and get the email ready
     foreach ($this->wantList as $info) {
         $listings = isset($info['listings']) ? $info['listings'] : array();
         $total = count($listings);
         if ($total > 0) {
             $this->message .= '<img src="' . $info['thumb'] . '" style="display:inline;float:left;margin-right: 5px;margin-bottom:10px;margin-top:50px;" />';
             $this->message .= '<h2 style="margin-top: 60px;"><a href="' . $info['discogs_url'] . '">' . $info['emailTitle'] . '</a> (' . $total . ')</h2>';
             $this->message .= '<table style="width:100%;border: 1px solid black;border-collapse: collapse;"><tr>';
             $this->message .= '<th style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">Title</th>';
             $this->message .= '<th style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">Location</th>';
             $this->message .= '<th style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">Condition</th>';
             $this->message .= '<th style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">Price</th>';
             $this->message .= '<th style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">Shipping</th>';
             $this->message .= '<th style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">Total</th></tr>';
             foreach ($listings as $listing) {
                 $this->message .= '<tr>';
                 $this->message .= '<td style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;"><a href="' . $listing['url'] . '">';
                 $this->message .= $listing['title'] . '</a></td>';
                 $this->message .= '<td style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">' . $listing['location'] . '</td>';
                 $this->message .= '<td style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">' . $listing['condition'] . '</td>';
                 $this->message .= '<td style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">$' . $listing['price'] . '</td>';
                 $this->message .= '<td style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">$' . $listing['shipping'] . '</td>';
                 $this->message .= '<td style="border: 1px solid black;border-collapse: collapse;padding: 5px;text-align: left;">$' . $listing['totalPrice'] . '</td>';
                 $this->message .= '</tr>';
             }
             $this->message .= '</table>';
         }
     }
 }