<commit_before>﻿import xbmcaddon
import xbmcgui
import xbmcplugin
import sys
import re
import urllib2

stream_sources = {
    'EBS TV': 'http://www.vixtream.net/vcdn/playerf.php?chan=ebstv',
    'EBC 1': 'http://www.vixtream.net/vcdn/ebctv.php',
    'EBC 2': 'http://www.vixtream.net/vcdn/ebctv.php?chan=ebc2',
    'EBC 3': 'http://www.vixtream.net/vcdn/ebctv.php?chan=ebc3'
}


def get_stream_urls():
    """Retrieves actual streamable URLs from the sources provided"""
    streams = {}
    for stream_source in stream_sources:
        source = urllib2.urlopen(stream_sources[stream_source]).read()
        try:
            regex = re.compile('file:\s*"(.+)"')
            streams[stream_source] = regex.search(source).group(1)
        except:
            streams[stream_source + '(Unavailable)'] = None
    return streams


def main():
    proc_handle = int(sys.argv[1]);
    stream_urls = get_stream_urls()

    for stream_url in stream_urls:

        # Show the listing
        listItem = xbmcgui.ListItem(stream_url)
        listItem.setIconImage('icon.png')
        xbmcplugin.addDirectoryItem(handle=proc_handle, url=stream_urls[stream_url], listitem=listItem)

    xbmcplugin.endOfDirectory(proc_handle)

main()<commit_msg>refactored minor issues in the stream loop<commit_after>﻿import xbmcaddon
import xbmcgui
import xbmcplugin
import sys
import re
import urllib2

stream_sources = {
    'EBS TV': 'http://www.vixtream.net/vcdn/playerf.php?chan=ebstv',
    'EBC 1': 'http://www.vixtream.net/vcdn/ebctv.php',
    'EBC 2': 'http://www.vixtream.net/vcdn/ebctv.php?chan=ebc2',
    'EBC 3': 'http://www.vixtream.net/vcdn/ebctv.php?chan=ebc3'
}

def get_stream_urls():
    """Retrieves actual streamable URLs from the sources provided"""
    streams = {}
    regex = re.compile('file:\s*"(.+)"')
    for stream_source in stream_sources:
        source = urllib2.urlopen(stream_sources[stream_source]).read()
        try:
            streams[stream_source] = regex.search(source).group(1)
        except:
            streams[stream_source + '(Unavailable)'] = None
    return streams


def main():
    proc_handle = int(sys.argv[1]);
    for stream_url in stream_urls:
        listItem = xbmcgui.ListItem(get_stream_urls())
        listItem.setIconImage('icon.png')
        xbmcplugin.addDirectoryItem(handle=proc_handle, url=stream_urls[stream_url], listitem=listItem)
    xbmcplugin.endOfDirectory(proc_handle)

main()
{'fraction_non_alphanumeric': 0.13454395377631037, 'fraction_numerical': 0.007428807263722658, 'mean_word_length': 3.5735849056603772, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4842888', 'n_tokens_mistral': 873, 'n_tokens_neox': 863, 'n_words': 148}