Subversion Repositories cheapmusic

Rev

Rev 129 | Rev 131 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 129 Rev 130
Line 18... Line 18...
18
    }
18
    }
19
 
19
 
20
    $arr = [];
20
    $arr = [];
21
    $products = [];
21
    $products = [];
22
    $cnt = 0;
22
    $cnt = 0;
23
    $wlAddArr = [];
-
 
24
    $wlSearchArr = [];
-
 
25
 
-
 
26
 
23
 
27
    libxml_use_internal_errors(true);
24
    libxml_use_internal_errors(true);
28
    $html = getSearchCache("amazon_scrape", $query, $searchCondition);
25
    $html = getSearchCache("amazon_scrape", $query, $searchCondition);
29
    if ($html === false) {
26
    if ($html === false) {
30
        $html = getUrl($urlDomain . "/s?k=" . rawurlencode($query) . "&i=popular&sf=qz&unfiltered=1&ref=nb_sb_noss");
27
        $html = getUrl($urlDomain . "/s?k=" . rawurlencode($query) . "&i=popular&sf=qz&unfiltered=1&ref=nb_sb_noss");
Line 161... Line 158...
161
            }
158
            }
162
 
159
 
163
            if (strpos($format, "Audio CD") === 0 ||
160
            if (strpos($format, "Audio CD") === 0 ||
164
                strpos($format, "Vinyl") === 0) {
161
                strpos($format, "Vinyl") === 0) {
165
                if ($needMatches) {
162
                if ($needMatches) {
166
                    addMatch_scrape($xh, $xpathPrd, ++$cnt, $title, $artists, $format, $releaseDate, $asin, $url, $pic, $wlAddArr, $wlSearchArr);
163
                    addMatch_scrape($xh, $xpathPrd, ++$cnt, $title, $artists, $format, $releaseDate, $asin, $url, $pic);
167
                }
164
                }
168
            }
165
            }
169
 
166
 
170
            $listings = $xpath->query('//div[contains(concat(" ", normalize-space(@class), " "), " olpOffer ")]');
167
            $listings = $xpath->query('//div[contains(concat(" ", normalize-space(@class), " "), " olpOffer ")]');
171
 
168
 
Line 286... Line 283...
286
 
283
 
287
    if ($needMatches) {
284
    if ($needMatches) {
288
        if ($cnt = 0) {
285
        if ($cnt = 0) {
289
            $_SESSION["discogs"] = "";
286
            $_SESSION["discogs"] = "";
290
        } else {
287
        } else {
291
            endMatches($xh, $wlAddArr, $wlSearchArr);
288
            endMatches($xh);
292
            
289
            
293
            $_SESSION["discogs"] = $xh->flush();
290
            $_SESSION["discogs"] = $xh->flush();
294
            //error_log(print_r($_SESSION["discogs"], 1));
291
            //error_log(print_r($_SESSION["discogs"], 1));
295
        }
292
        }
296
    }
293
    }
297
 
294
 
298
    return ($arr);
295
    return ($arr);
299
}
296
}
300
 
297
 
301
function addMatch_scrape(&$xh, $xpath, $cnt, $title, $artists, $mediaType, $releaseDate, $asin, $url, $pic, &$wlAddArr, &$wlSearchArr) {
298
function addMatch_scrape(&$xh, $xpath, $cnt, $title, $artists, $mediaType, $releaseDate, $asin, $url, $pic) {
302
    $nodes = $xpath->query('//table[@id="productDetailsTable"]//ul/li');
299
    $nodes = $xpath->query('//table[@id="productDetailsTable"]//ul/li');
303
    if ($nodes->length < 1) {
300
    if ($nodes->length < 1) {
304
        return;
301
        return;
305
    }
302
    }
306
 
303
 
Line 422... Line 419...
422
    $item->ItemInfo->addChild('MediaType', $mediaType);
419
    $item->ItemInfo->addChild('MediaType', $mediaType);
423
    $item->ItemInfo->addChild('Edition', $edition);
420
    $item->ItemInfo->addChild('Edition', $edition);
424
    $item->ItemInfo->addChild('Genre', $genre);
421
    $item->ItemInfo->addChild('Genre', $genre);
425
    $item->ItemInfo->addChild('RunningTime', (int)$runTime);
422
    $item->ItemInfo->addChild('RunningTime', (int)$runTime);
426
 
423
 
427
    $_SESSION["discogs"] .= addMatch($xh, $item, $cnt, $mediaType, $wlAddArr, $wlSearchArr);
424
    $_SESSION["discogs"] .= addMatch($xh, $item, $cnt, $mediaType);
428
}
425
}