<commit_before>import sys
import urllib
import os
import json
import xbmcgui
import xbmcplugin
import control
from BeautifulSoup import SoupStrainer
from BeautifulSoup import BeautifulSoup
import http_request

url_root = "https://mva.microsoft.com/"
url_api = "https://api-mlxprod.microsoft.com/"
url_api_courses = "%ssdk/search/v1.0/5/courses?$skip=%i&$top=%i"
url_course = "en-us/training-courses/course-%s"

icon_folder = os.path.join(control.imagesPath, "folder.png")
icon_search = os.path.join(control.imagesPath, "search.png")
icon_next = os.path.join(control.imagesPath, "next-page.png")
icon_settings = os.path.join(control.imagesPath, "settings.png")

text_green = "[B][COLOR green][UPPERCASE]%s[/UPPERCASE][/COLOR][/B]"

ignore_sections = ["LCID", "Format"]
section_ids = [30201, 30202, 30203, 30204, 30205]
default_filter = {"SelectCriteria": [], "DisplayFields": [],
               "SortOptions": [{"SortOnField": "Relevance", "SortOrder": 1}], "SearchKeyword": "",
               "UILangaugeCode": "1033", "UserLanguageCode": "1033"}
default_lanugage = {"SelectOnField": "LCID", "SelectTerm": "1033", "SelectMatchOption": 2}

def add_video(title, thumbnail, plot, genre, video_url):
    list_item = control.item(title, iconImage="DefaultVideo.png", thumbnailImage=thumbnail, path=video_url)
    list_item.setInfo("video", {"Title": title, "Studio": "Microsoft Channel 9", "Plot": plot, "Genre": genre})
    list_item.setArt({"thumb": thumbnail, "fanart": thumbnail, "landscape": thumbnail, "poster": thumbnail})
    plugin_play_url = '%s?action=play&video_url=%s' % (sys.argv[0], urllib.quote_plus(video_url))
    control.addItem(handle=int(sys.argv[1]), url=plugin_play_url, listitem=list_item, isFolder=False)


def add_next_page(item_url, page):
    list_item = control.item(text_green % (control.lang(30500) % page),
                             iconImage=icon_next, thumbnailImage=icon_next)
    control.addItem(handle=int(sys.argv[1]), url=item_url, listitem=list_item, isFolder=True)
    return


def language_filter():
    # {SelectOnField: "LCID", SelectTerm: "1045", SelectMatchOption: 2}
    result = []
    setting_lang_items = control.lang(30600).split(",")
    for lang_item in setting_lang_items:
        lang_enabled = control.setting(lang_item)
        if lang_enabled == "true":
            result.append({"SelectOnField": "LCID", "SelectTerm": "%s" % lang_item, "SelectMatchOption": 2})

    if not result:
        return default_lanugage

    return result


def create_filter_criteria(section, topic, search_term=None):
    if section == "" or topic == "":<commit_msg>fixed the playback issue i introduced<commit_after>import sys
import urllib
import os
import json
import xbmcgui
import xbmcplugin
import control
from BeautifulSoup import SoupStrainer
from BeautifulSoup import BeautifulSoup
import http_request

url_root = "https://mva.microsoft.com/"
url_api = "https://api-mlxprod.microsoft.com/"
url_api_courses = "%ssdk/search/v1.0/5/courses?$skip=%i&$top=%i"
url_course = "en-us/training-courses/course-%s"

icon_folder = os.path.join(control.imagesPath, "folder.png")
icon_search = os.path.join(control.imagesPath, "search.png")
icon_next = os.path.join(control.imagesPath, "next-page.png")
icon_settings = os.path.join(control.imagesPath, "settings.png")

text_green = "[B][COLOR green][UPPERCASE]%s[/UPPERCASE][/COLOR][/B]"

ignore_sections = ["LCID", "Format"]
section_ids = [30201, 30202, 30203, 30204, 30205]
default_filter = {"SelectCriteria": [], "DisplayFields": [],
               "SortOptions": [{"SortOnField": "Relevance", "SortOrder": 1}], "SearchKeyword": "",
               "UILangaugeCode": "1033", "UserLanguageCode": "1033"}
default_lanugage = {"SelectOnField": "LCID", "SelectTerm": "1033", "SelectMatchOption": 2}

def add_video(title, thumbnail, plot, genre, video_url):
    list_item = control.item(title, iconImage="DefaultVideo.png", thumbnailImage=thumbnail)
    list_item.setInfo("video", {"Title": title, "Studio": "Microsoft Channel 9", "Plot": plot, "Genre": genre})
    list_item.setArt({"thumb": thumbnail, "fanart": thumbnail, "landscape": thumbnail, "poster": thumbnail})
    plugin_play_url = '%s?action=play&video_url=%s' % (sys.argv[0], urllib.quote_plus(video_url))
    control.addItem(handle=int(sys.argv[1]), url=plugin_play_url, listitem=list_item, isFolder=False)


def add_next_page(item_url, page):
    list_item = control.item(text_green % (control.lang(30500) % page),
                             iconImage=icon_next, thumbnailImage=icon_next)
    control.addItem(handle=int(sys.argv[1]), url=item_url, listitem=list_item, isFolder=True)
    return


def language_filter():
    # {SelectOnField: "LCID", SelectTerm: "1045", SelectMatchOption: 2}
    result = []
    setting_lang_items = control.lang(30600).split(",")
    for lang_item in setting_lang_items:
        lang_enabled = control.setting(lang_item)
        if lang_enabled == "true":
            result.append({"SelectOnField": "LCID", "SelectTerm": "%s" % lang_item, "SelectMatchOption": 2})

    if not result:
        return default_lanugage

    return result


def create_filter_criteria(section, topic, search_term=None):
    if section == "" or topic == "":
{'fraction_non_alphanumeric': 0.15272448196469685, 'fraction_numerical': 0.023791250959324637, 'mean_word_length': 5.068684516880093, 'pattern_counts': {'":': 48, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, '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': '5593622', 'n_tokens_mistral': 1833, 'n_tokens_neox': 1737, 'n_words': 344}