<commit_before><?php
	require_once dirname(__FILE__).'/util.php';
	
	// -------------------- Functions ----------------------

    # Suppress DOM warnings
    libxml_use_internal_errors(true);
    
    function wgetEpisodesWeekarchief($ug_search_url, $max_pages, $page_offset = 1)
	{
		$episodes = array(); // result

		$itemQueries = array(); // result
		$itemQueries['program'] = "h2/a";
		$itemQueries['episode'] = "h3/a";
		$itemQueries['href'] = "h3/a/@href";
        $itemQueries['data-images'] = "../div[@class='image']/a/img/@data-images";

		$result = privWgetEpisodes($ug_search_url, "//li[@class='broadcast active']/div[@class='info']", $itemQueries, $max_pages, $page_offset);
		foreach($result as $item)
		{
			$images = explode(',', trim($item['data-images'], '[]'));
            $img = trim($images[0], '"');
            $episodes[] = array(
				'refid' => substr($item['href'], 14),
				'title' => $item['program'].' - '.$item['episode'],
                'img'   => str_replace('140x79', '280x148', $img)
			);
		}
		return $episodes;
	}
	
	function wgetEpisodesByProgram($ug_search_url, $max_pages, $page_offset = 1)
	{
		$episodes = array(); // result

		$itemQueries = array(
            'episode' => 'h3/a',
            'href'    => 'h3/a/@href');

		$result = privWgetEpisodes($ug_search_url, "//ul/li[@class='episode active knav']/div[@class='description']", $itemQueries, $max_pages, $page_offset);
		foreach($result as $item)
		{
			$episodes[] = array(
				'refid' => substr($item['href'], 14),
				//'remoteepiid' => $item['data-remote-id'],
				'title' => $item['episode']
			);
		}
		return $episodes;
	}
    
    function wgetProgramsAZ($suffix, $max_pages, $page_offset)
    {
        return wgetPrograms('http://www.uitzendinggemist.nl/programmas/'.$suffix.'?display_mode=detail', $max_pages, $page_offset);
    }
    
    function wgetPrograms($ug_search_url, $max_pages = 1, $page_offset = 1)
    {
        $itemQueries = array(); // result
		$itemQueries['name'] = "h2/a";
		$itemQueries['href'] = "h2/a/@href";
        $itemQueries['data-images'] = "../div[@class='image']/a/img/@data-images";
        
        $query="/html//li[@class='series']/div[@class='info']";
		
        return privWgetEpisodes($ug_search_url, $query, $itemQueries, $max_pages, $page_offset);
    }
    
    function wgetSearchPrograms($ug_search_url, $max_pages = 1, $page_offset = 1)
    {
        $itemQueries = array(); // result
		$itemQueries['name'] = "h3/a";
		$itemQueries['href'] = "h3/a/@href";
        $itemQueries['data-images'] = "div[@class='img']/a/img/@data-images";
        
        $query="//ul[@id='series-result']/li[@class='series knav']/div[@class='wrapper']";
		
        return privWgetEpisodes($ug_search_url, $query, $itemQueries, $max_pages, $page_offset);<commit_msg>Added images to episode (afleveringen) list.<commit_after><?php
	require_once dirname(__FILE__).'/util.php';
	
	// -------------------- Functions ----------------------

    # Suppress DOM warnings
    libxml_use_internal_errors(true);
    
    function wgetEpisodesWeekarchief($ug_search_url, $max_pages, $page_offset = 1)
	{
		$episodes = array(); // result

		$itemQueries = array(); // result
		$itemQueries['program'] = "h2/a";
		$itemQueries['episode'] = "h3/a";
		$itemQueries['href'] = "h3/a/@href";
        $itemQueries['data-images'] = "../div[@class='image']/a/img/@data-images";

		$result = privWgetEpisodes($ug_search_url, "//li[@class='broadcast active']/div[@class='info']", $itemQueries, $max_pages, $page_offset);
		foreach($result as $item)
		{
			$episodes[] = array(
				'refid' => substr($item['href'], 14),
				'title' => $item['program'].' - '.$item['episode'],
                'img'   =>  getImgSrcFromDataImages($item['data-images'])
			);
		}
		return $episodes;
	}
	
	function wgetEpisodesByProgram($ug_search_url, $max_pages, $page_offset = 1)
	{
		$episodes = array(); // result

        $itemQueries = array(
            'episode' => 'h3/a',
            'href'    => 'h3/a/@href',
            'data-images' => "../div[@class='image']/a/img/@data-images");

		$result = privWgetEpisodes($ug_search_url, "//ul/li[@class='episode active knav']/div[@class='description']", $itemQueries, $max_pages, $page_offset);
		foreach($result as $item)
		{
			$episodes[] = array(
				'refid' => substr($item['href'], 14),
                'img' => getImgSrcFromDataImages($item['data-images']),
				'title' => $item['episode']
			);
		}
		return $episodes;
	}
    
    function getImgSrcFromDataImages($data_images)
    {
        $images = explode(',', trim($data_images, '[]'));
        $img = trim($images[0], '"');
        return str_replace('140x79', '280x148', $img);
    }
    
    function wgetProgramsAZ($suffix, $max_pages, $page_offset)
    {
        return wgetPrograms('http://www.uitzendinggemist.nl/programmas/'.$suffix.'?display_mode=detail', $max_pages, $page_offset);
    }
    
    function wgetPrograms($ug_search_url, $max_pages = 1, $page_offset = 1)
    {
        $itemQueries = array(); // result
		$itemQueries['name'] = "h2/a";
		$itemQueries['href'] = "h2/a/@href";
        $itemQueries['data-images'] = "../div[@class='image']/a/img/@data-images";
        
        $query="/html//li[@class='series']/div[@class='info']";
		
        return privWgetEpisodes($ug_search_url, $query, $itemQueries, $max_pages, $page_offset);
    }
    
    function wgetSearchPrograms($ug_search_url, $max_pages = 1, $page_offset = 1)
    {
        $itemQueries = array(); // result
		$itemQueries['name'] = "h3/a";
		$itemQueries['href'] = "h3/a/@href";
        $itemQueries['data-images'] = "div[@class='img']/a/img/@data-images";
        
        $query="//ul[@id='series-result']/li[@class='series knav']/div[@class='wrapper']";
		
        return privWgetEpisodes($ug_search_url, $query, $itemQueries, $max_pages, $page_offset);
{'fraction_non_alphanumeric': 0.21594400819392284, 'fraction_numerical': 0.010583817002389894, 'mean_word_length': 3.2364425162689803, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '654665', 'n_tokens_mistral': 2259, 'n_tokens_neox': 2079, 'n_words': 300}