Ejemplo n.º 1
0
/**
 * Load all items present in a section
 **/
function load_items_for_section($section)
{
    global $options;
    $url = $options['plex-url'] . 'library/sections/' . $section['key'] . '/all';
    $xml = load_xml_from_url($url);
    if (!$xml) {
        return false;
    }
    $num_items = intval($xml->attributes()->size);
    if ($num_items <= 0) {
        plex_error('No items were found in this section, skipping');
        return false;
    }
    switch ($section['type']) {
        case 'movie':
            $object_to_loop = $xml->Video;
            $object_parser = 'load_data_for_movie';
            break;
        case 'show':
            $object_to_loop = $xml->Directory;
            $object_parser = 'load_data_for_show';
            break;
        default:
            plex_error('Unknown section type provided to parse: ' . $section['type']);
            return false;
    }
    plex_log('Found ' . $num_items . ' ' . hl_inflect($num_items, $section['type']) . ' in ' . $section['title']);
    $items = array();
    foreach ($object_to_loop as $el) {
        $item = $object_parser($el);
        if ($item) {
            $items[$item['key']] = $item;
        }
    }
    return $items;
}
Ejemplo n.º 2
0
function proxy_simplexml_load_file($url)
{
    $xml_string = '';
    ini_set('user_agent', $_SERVER['HTTP_USER_AGENT']);
    $xml = load_xml_from_url($url);
    #JSTOR hack
    if (empty($xml) && strpos($url, 'jstor') !== false) {
        $xml = new XMLReader();
        $xml->open($url);
    }
    return $xml;
}