Ejemplo n.º 1
0
def play(anime_id, episode_id):

    episode_link = episode_id
	
    l1 = "Fetching video."
    progressDialog.create(heading="Masterani", line1="Fetching video.")
    progressDialog.update(0, line1=l1, line3="Loading hosts.")
    
    hosts = getlinks(episode_link)   
    ep_id = getid(episode_link)
    #linkforcover = getcover(episode_link)
	
    if hosts is None:
        xbmcgui.Dialog().ok("Masterani", "Something went wrong.", "Please try again later.")
        return

		
    #Remove Tiwi Kiwi as it is broken
	
    for e in hosts:
        if 'Tiwi.kiwi' in e['name']:
            hosts.remove(e)

    #Remove Disabled Hosts

    if control.setting("host.mp4upload") == "false":
            for e in hosts:
                if 'MP4Upload' in e['name']:
                    hosts.remove(e)

    if control.setting("host.aniupload") == "false":
        for e in hosts:
            if 'Aniupload' in e['name']:
                hosts.remove(e)

    if control.setting("host.bakavide") == "false":
        for e in hosts:
            if 'Bakavideo' in e['name']:
                hosts.remove(e)

    if control.setting("host.youtube") == "false":
        for e in hosts:
            if 'YouTube' in e['name']:
                hosts.remove(e)

    if control.setting("host.beta") == "false":
        for e in hosts:
            if 'Beta' in e['name']:
                hosts.remove(e)
        
    if control.setting("host.stream.moe") == "false":
        for e in hosts:
            if 'Stream.moe' in e['name']:
                hosts.remove(e)

    if control.setting("host.drive.g") == "false":
        for e in hosts:
            if 'Drive.g' in e['name']:
                hosts.remove(e)
                
    if control.setting("host.vidstreaming") == "false":
        for e in hosts:
            if 'Vidstreaming' in e['name']:
                hosts.remove(e)
            
    if control.setting("host.rapidvideo") == "false":
        for e in hosts:
            if 'Rapidvideo' in e['name']:
                hosts.remove(e)

    if control.setting("host.aika") == "false":
        for e in hosts:
            if 'Aika' in e['name']:
                hosts.remove(e)

    if control.setting("host.streamango") == "false":
        for e in hosts:
            if 'Streamango' in e['name']:
                hosts.remove(e)
        
    if control.setting("host.openload") == "false":
        for e in hosts:
            if 'Openload' in e['name']:
                hosts.remove(e)

    progressDialog.update(25, line1=l1, line3="Loading episodes urls.")
    progressDialog.update(50, line1=l1, line3="Picking nose.")

    hostlist = []

    videos = sorted(hosts, key=lambda k: (-int(k['type']), int(k['quality'])), reverse=True)
    print videos

    autoplay = control.setting("autoplay.enabled")
    maxq = control.setting("autoplay.maxquality")
    subdub = control.setting("autoplay.subdub")

    videoCounter = 0
    autoplayHost = 0
    hostCounter = 0

    while videoCounter < len(videos):
        try:
            hostname = videos[videoCounter]['name']
            subs = 'Sub' if videos[videoCounter]['type'] is 1 else 'Dub'
            quality = videos[videoCounter]['quality']
            if 'true' in autoplay:
                if subdub == subs and int(quality) <= int(maxq):
                    hostlist.append("%s | %s | %s" % (quality, subs, hostname))
                    autoplayHost = hostCounter
                    break
                hostCounter += 1
            else:
                hostlist.append("%s | %s | %s" % (quality, subs, hostname))
            videoCounter += 1
        except:
            videos.remove(videos[videoCounter])

    if len(hostlist) is 0:
        progressDialog.close()
        xbmcgui.Dialog().ok("Masterani Redux", "No supported hosts found.")
        return

    if 'false' in autoplay:
        hostDialog = control.dialog.select("Select host.", hostlist)
    else:
        if len(hostlist) is 0:
            progressDialog.close()
            xbmcgui.Dialog().ok("Masterani Redux", "No hosts found for autoplay.", "Change addon settings and try again.")
            hostDialog = -1
        else:
            hostDialog = autoplayHost
			
    if hostDialog == -1:
        progressDialog.close()
        control.execute('dialog.close(okdialog)')
        return

    hostname = videos[hostDialog]['name']		
    hostlink = videos[hostDialog]['url']
    hostquality = videos[hostDialog]['quality']
    embed_id = videos[hostDialog]['embed_id']

    progressDialog.update(75, line1=l1, line3="Loading video.")
	
    #Resolve Links
    mp4 = getdirect(hostname, hostlink, hostquality, embed_id)
    progressDialog.close()
    MAPlayer().run(anime_id, ep_id, mp4)
Ejemplo n.º 2
0
def play(anime_id, episode_id):
    # try:
    # content = cache.get(masterani.get_anime_details(anime_id), 2)

    l1 = "Fetching video"
    progressDialog.create(heading="MasterAni", line1="Fetching video")
    progressDialog.update(0, line1=l1, line3="Loading hosts")
    hosts = client.request("http://www.masterani.me/api/hosts")
    hosts = json.loads(hosts)

    progressDialog.update(25, line1=l1, line3="Loading episodes urls")

    videos = client.request("http://www.masterani.me/api/episode/%s?videos=1" %
                            episode_id)
    videos = json.loads(videos)['videos']
    progressDialog.update(50, line1=l1, line3="Picking nose")

    hostlist = []

    videos = sorted(videos,
                    key=lambda k: (int(k['quality']), int(k['type'])),
                    reverse=True)

    autoplay = control.setting("autoplay.enabled")
    maxq = control.setting("autoplay.maxquality")
    subdub = control.setting("autoplay.subdub")

    for video in videos:
        hostname = [
            x['name'] for x in hosts if int(x['id']) == int(video['host_id'])
        ][0]
        subs = 'Sub' if video['type'] is 1 else 'Dub'
        quality = video['quality']
        if 'true' in autoplay:
            if subdub in subs and int(quality) <= int(maxq):
                hostlist.append("%s | %s | %s" % (quality, subs, hostname))
        else:
            hostlist.append("%s | %s | %s" % (quality, subs, hostname))

    if autoplay in 'false':
        hostdialog = control.dialog.select("Select host", hostlist)
    else:
        if len(hostlist) is 0:
            progressDialog.close()
            xbmcgui.Dialog().ok("Masterani", "No hosts found for autoplay.",
                                "Change addon settings and try again.")
            hostdialog = -1
        else:
            hostdialog = 0

    if hostdialog == -1:
        progressDialog.close()
        control.execute('Dialog.Close(okdialog)')
        return

    host_id = videos[hostdialog]['host_id']
    embed_id = videos[hostdialog]['embed_id']
    if host_id is '':
        return

    prefix = ""
    suffix = ""

    for host in hosts:
        if str(host_id) in str(host['id']):
            prefix = host['embed_prefix']
            suffix = host['embed_suffix']
            break

    try:
        if suffix is not None:
            url = prefix + embed_id + suffix
        else:
            url = prefix + embed_id
    except:
        pass

    progressDialog.update(75, line1=l1, line3="Loading video")
    if 'moe' in host['name']:
        content = base64.b64decode(
            re.compile("atob\('(.+?)'\)").findall(client.request(url))[0])
        mp4 = re.compile("source src=\"(.+?)\"").findall(content)[0]
    if 'MP4Upload' in host['name']:
        mp4 = re.compile("\"file\": \"(.+?)\"").findall(client.request(url))[0]
    if 'Bakavideo' in host['name']:
        content = re.compile("go\((.+?)\)").findall(client.request(url))[0]
        content = content.replace("'", "").replace(", ", "/")
        content = "https://bakavideo.tv/" + content
        content = client.request(content)
        content = json.loads(content)
        content = content['content']
        content = base64.b64decode(content)
        mp4 = client.parseDOM(content, 'source', ret='src')[0]
    if 'BETA' in host['name']:
        mp4 = embed_id
    if 'Vidstream' in host['name']:
        mp4 = re.compile("source src='(.+?)'").findall(client.request(url))[0]
    if 'Aniupload' in host['name']:
        mp4 = re.compile("\(\[\{src: \"(.+?)\"").findall(
            client.request(url))[0]
    if 'Drive.g' in host['name']:
        mp4 = re.compile("url_encoded_fmt_stream_map\",\"(.+?)\"\]").findall(
            client.request(url))[0]
        mp4 = mp4.split(",")[0]
        mp4 = mp4[mp4.find("https"):]
        mp4 = urllib.unquote(mp4)

    progressDialog.close()
    control.sleep(100)
    MAPlayer().run(anime_id, episode_id, mp4)
Ejemplo n.º 3
0
def play(anime_id, episode_id):

    #global count
    #count = count + 1
    
    episode_link = episode_id
    episode_number = episode_link.split("/", 6)[6]
	
    l1 = "Fetching video."
    progressDialog.create(heading="Masterani Redux", line1="Fetching video.")
    progressDialog.update(0, line1=l1, line3="Loading hosts.")
    
    hosts = getlinks(episode_link)[0]   
    ep_id = getlinks(episode_link)[1]
    #linkforcover = getcover(episode_link)

    if hosts is None:
        xbmcgui.Dialog().ok("Masterani Redux", "Something went wrong.", "Please try again later.")
        return

    #Remove Disabled Hosts

    if control.setting("host.mystream") == "false":
            for e in hosts:
                if 'Mystream' in e['name']:
                    hosts.remove(e)

    if control.setting("host.mp4upload") == "false":
            for e in hosts:
                if 'MP4Upload' in e['name']:
                    hosts.remove(e)

    if control.setting("host.youtube") == "false":
        for e in hosts:
            if 'YouTube' in e['name']:
                hosts.remove(e)
        
    if control.setting("host.stream.moe") == "false":
        for e in hosts:
            if 'Stream.moe' in e['name']:
                hosts.remove(e)

    if control.setting("host.drive.g") == "false":
        for e in hosts:
            if 'Drive.g' in e['name']:
                hosts.remove(e)
                
    if control.setting("host.vidstreaming") == "false":
        for e in hosts:
            if 'Vidstreaming' in e['name']:
                hosts.remove(e)
            
    if control.setting("host.rapidvideo") == "false":
        for e in hosts:
            if 'Rapidvideo' in e['name']:
                hosts.remove(e)

    if control.setting("host.aika") == "false":
        for e in hosts:
            if 'Aika' in e['name']:
                hosts.remove(e)

    if control.setting("host.streamango") == "false":
        for e in hosts:
            if 'Streamango' in e['name']:
                hosts.remove(e)
        
    if control.setting("host.openload") == "false":
        for e in hosts:
            if 'Openload' in e['name']:
                hosts.remove(e)
                
    if control.setting("host.tiwikiwi") == "false":
        for e in hosts:
            if 'Streamango' in e['name']:
                hosts.remove(e)

    progressDialog.update(25, line1=l1, line3="Loading episodes urls.")
    progressDialog.update(50, line1=l1, line3="Picking nose.")

    hostlist = []

    videos = sorted(hosts, key=lambda k: (-int(k['type']), int(k['quality'])), reverse=True)
    print videos

    autoplay = control.setting("autoplay.enabled")
    maxq = control.setting("autoplay.maxquality")
    subdub = control.setting("autoplay.subdub")

    videoCounter = 0
    autoplayHost = 0
    hostCounter = 0
    
    autovids = []
    

#    while videoCounter < len(videos):
#        try:
#            hostname = videos[videoCounter]['name']
#            subs = 'Sub' if videos[videoCounter]['type'] is 1 else 'Dub'
#            quality = videos[videoCounter]['quality']
#            if 'true' in autoplay:
#                if subdub == subs and int(quality) <= int(maxq):
#                    hostlist.append("%s | %s | %s" % (quality, subs, hostname))
#                    autoplayHost = hostCounter
#                    break
#                hostCounter += 1
#            else:
#                hostlist.append("%s | %s | %s" % (quality, subs, hostname))
#            videoCounter += 1
#        except:
#            videos.remove(videos[videoCounter])


    while videoCounter < len(videos):      
        try:
            hostname = videos[videoCounter]['name']
            subs = 'Sub' if videos[videoCounter]['type'] is 1 else 'Dub'
            quality = videos[videoCounter]['quality']
            if 'true' in autoplay:
                if subdub == subs and int(quality) <= int(maxq):
                    hostlist.append("%s | %s | %s" % (quality, subs, hostname))    
                    autovids.append(videos[videoCounter])                
            else:
                hostlist.append("%s | %s | %s" % (quality, subs, hostname))
            videoCounter += 1
        except:
            videos.remove(videos[videoCounter])


            
    if len(hostlist) is 0:
        progressDialog.close()
        xbmcgui.Dialog().notification("Masterani Redux", "No supported hosts found.")
        return

    if 'false' in autoplay:
        hostDialog = control.dialog.select("Select host.", hostlist)
    else:
        if len(hostlist) is 0:
            progressDialog.close()
            xbmcgui.Dialog().notification("Masterani Redux", "No hosts found for autoplay. Change addon settings and try again.")
            hostDialog = -1
        else:
            hostDialog = autoplayHost
			
    if hostDialog == -1:
        progressDialog.close()
        control.execute('dialog.close(okdialog)')
        return

    if 'true' in autoplay:
        try:
            hostname = autovids[hostDialog]['name']		
            hostlink = autovids[hostDialog]['url']
            hostquality = autovids[hostDialog]['quality']
            embed_id = autovids[hostDialog]['embed_id']   
        except:
            xbmcgui.Dialog().notification("Masterani Redux", "You have attempted all the hosts")
    else:        
        hostname = videos[hostDialog]['name']		
        hostlink = videos[hostDialog]['url']
        hostquality = videos[hostDialog]['quality']
        embed_id = videos[hostDialog]['embed_id']
	
    c = cache.get(masterani.get_anime_details, 3, anime_id)
    syn = c['plot'].encode('utf-8')
    print syn
    start_date = c['premiered']
    print start_date 
    sty = c['premiered'].split("-", 1)[0]
    print sty
    gen = str(c['genre'])
    print gen
    epcount = c['episode_count']

    progressDialog.update(75, line1=l1, line3="Loading video.")
	
    #Resolve Links
    mp4 = getdirect(hostname, hostlink, hostquality, embed_id)
    progressDialog.close()
    MAPlayer().run(anime_id, ep_id, mp4, syn, start_date, sty, gen, episode_number, epcount, episode_link)
Ejemplo n.º 4
0
def play(anime_id, episode_id):
    # try:
        # content = cache.get(masterani.get_anime_details(anime_id), 2)

        l1 = "Fetching video"
        progressDialog.create(heading="MasterAni", line1="Fetching video")
        progressDialog.update(0, line1=l1, line3="Loading hosts")
        hosts = client.request("http://www.masterani.me/api/hosts")
        hosts = json.loads(hosts)

        progressDialog.update(25, line1=l1, line3="Loading episodes urls")

        videos = client.request("http://www.masterani.me/api/episode/%s?videos=1" % episode_id)
        videos = json.loads(videos)['videos']
        progressDialog.update(50, line1=l1, line3="Picking nose")

        hostlist = []

        videos = sorted(videos, key=lambda k: (int(k['quality']), int(k['type'])), reverse=True)

        autoplay = control.setting("autoplay.enabled")
        maxq = control.setting("autoplay.maxquality")
        subdub = control.setting("autoplay.subdub")

        for video in videos:
            hostname = [x['name'] for x in hosts if int(x['id']) == int(video['host_id'])][0]
            subs = 'Sub' if video['type'] is 1 else 'Dub'
            quality = video['quality']
            if 'true' in autoplay:
                if subdub in subs and int(quality) <= int(maxq):
                    hostlist.append("%s | %s | %s" % (quality, subs, hostname))
            else:
                hostlist.append("%s | %s | %s" % (quality, subs, hostname))

        if autoplay in 'false':
            hostdialog = control.dialog.select("Select host", hostlist)
        else:
            if len(hostlist) is 0:
                progressDialog.close()
                xbmcgui.Dialog().ok("Masterani", "No hosts found for autoplay.", "Change addon settings and try again.")
                hostdialog = -1
            else:
                hostdialog = 0

        if hostdialog == -1:
            progressDialog.close()
            control.execute('Dialog.Close(okdialog)')
            return

        host_id = videos[hostdialog]['host_id']
        embed_id = videos[hostdialog]['embed_id']
        if host_id is '':
            return

        prefix = ""
        suffix = ""

        for host in hosts:
            if str(host_id) in str(host['id']):
                prefix = host['embed_prefix']
                suffix = host['embed_suffix']
                break

        try:
            if suffix is not None:
                url = prefix + embed_id + suffix
            else:
                url = prefix + embed_id
        except:
            pass

        progressDialog.update(75, line1=l1, line3="Loading video")
        if 'moe' in host['name']:
            content = base64.b64decode(re.compile("atob\('(.+?)'\)").findall(client.request(url))[0])
            mp4 = re.compile("source src=\"(.+?)\"").findall(content)[0]
        if 'MP4Upload' in host['name']:
            mp4 = re.compile("\"file\": \"(.+?)\"").findall(client.request(url))[0]
        if 'Bakavideo' in host['name']:
            content = re.compile("go\((.+?)\)").findall(client.request(url))[0]
            content = content.replace("'", "").replace(", ", "/")
            content = "https://bakavideo.tv/" + content
            content = client.request(content)
            content = json.loads(content)
            content = content['content']
            content = base64.b64decode(content)
            mp4 = client.parseDOM(content, 'source', ret='src')[0]
        if 'BETA' in host['name']:
            mp4 = embed_id
        if 'Vidstream' in host['name']:
            mp4 = re.compile("source src='(.+?)'").findall(client.request(url))[0]
        if 'Aniupload' in host['name']:
            mp4 = re.compile("\(\[\{src: \"(.+?)\"").findall(client.request(url))[0]
        if 'Drive.g' in host['name']:
            mp4 = re.compile("url_encoded_fmt_stream_map\",\"(.+?)\"\]").findall(client.request(url))[0]
            mp4 = mp4.split(",")[0]
            mp4 = mp4[mp4.find("https"):]
            mp4 = urllib.unquote(mp4)

        progressDialog.close()
        control.sleep(100)
        MAPlayer().run(anime_id, episode_id, mp4)
Ejemplo n.º 5
0
def play(anime_id, episode_id):

    #global count
    #count = count + 1

    episode_link = episode_id
    episode_number = episode_link.split("/", 6)[6]

    l1 = "Fetching video."
    progressDialog.create(heading="Masterani Redux", line1="Fetching video.")
    progressDialog.update(0, line1=l1, line3="Loading hosts.")

    hosts = getlinks(episode_link)[0]
    ep_id = getlinks(episode_link)[1]
    #linkforcover = getcover(episode_link)

    if hosts is None:
        xbmcgui.Dialog().ok("Masterani Redux", "Something went wrong.",
                            "Please try again later.")
        return

    #Remove Disabled Hosts

    if control.setting("host.mystream") == "false":
        for e in hosts:
            if 'Mystream' in e['name']:
                hosts.remove(e)

    if control.setting("host.mp4upload") == "false":
        for e in hosts:
            if 'MP4Upload' in e['name']:
                hosts.remove(e)

    if control.setting("host.youtube") == "false":
        for e in hosts:
            if 'YouTube' in e['name']:
                hosts.remove(e)

    if control.setting("host.stream.moe") == "false":
        for e in hosts:
            if 'Stream.moe' in e['name']:
                hosts.remove(e)

    if control.setting("host.drive.g") == "false":
        for e in hosts:
            if 'Drive.g' in e['name']:
                hosts.remove(e)

    if control.setting("host.vidstreaming") == "false":
        for e in hosts:
            if 'Vidstreaming' in e['name']:
                hosts.remove(e)

    if control.setting("host.rapidvideo") == "false":
        for e in hosts:
            if 'Rapidvideo' in e['name']:
                hosts.remove(e)

    if control.setting("host.aika") == "false":
        for e in hosts:
            if 'Aika' in e['name']:
                hosts.remove(e)

    if control.setting("host.streamango") == "false":
        for e in hosts:
            if 'Streamango' in e['name']:
                hosts.remove(e)

    if control.setting("host.openload") == "false":
        for e in hosts:
            if 'Openload' in e['name']:
                hosts.remove(e)

    if control.setting("host.tiwikiwi") == "false":
        for e in hosts:
            if 'Streamango' in e['name']:
                hosts.remove(e)

    progressDialog.update(25, line1=l1, line3="Loading episodes urls.")
    progressDialog.update(50, line1=l1, line3="Picking nose.")

    hostlist = []

    videos = sorted(hosts,
                    key=lambda k: (-int(k['type']), int(k['quality'])),
                    reverse=True)
    print videos

    autoplay = control.setting("autoplay.enabled")
    maxq = control.setting("autoplay.maxquality")
    subdub = control.setting("autoplay.subdub")

    videoCounter = 0
    autoplayHost = 0
    hostCounter = 0

    autovids = []

    #    while videoCounter < len(videos):
    #        try:
    #            hostname = videos[videoCounter]['name']
    #            subs = 'Sub' if videos[videoCounter]['type'] is 1 else 'Dub'
    #            quality = videos[videoCounter]['quality']
    #            if 'true' in autoplay:
    #                if subdub == subs and int(quality) <= int(maxq):
    #                    hostlist.append("%s | %s | %s" % (quality, subs, hostname))
    #                    autoplayHost = hostCounter
    #                    break
    #                hostCounter += 1
    #            else:
    #                hostlist.append("%s | %s | %s" % (quality, subs, hostname))
    #            videoCounter += 1
    #        except:
    #            videos.remove(videos[videoCounter])

    while videoCounter < len(videos):
        try:
            hostname = videos[videoCounter]['name']
            subs = 'Sub' if videos[videoCounter]['type'] is 1 else 'Dub'
            quality = videos[videoCounter]['quality']
            if 'true' in autoplay:
                if subdub == subs and int(quality) <= int(maxq):
                    hostlist.append("%s | %s | %s" % (quality, subs, hostname))
                    autovids.append(videos[videoCounter])
            else:
                hostlist.append("%s | %s | %s" % (quality, subs, hostname))
            videoCounter += 1
        except:
            videos.remove(videos[videoCounter])

    if len(hostlist) is 0:
        progressDialog.close()
        xbmcgui.Dialog().notification("Masterani Redux",
                                      "No supported hosts found.")
        return

    if 'false' in autoplay:
        hostDialog = control.dialog.select("Select host.", hostlist)
    else:
        if len(hostlist) is 0:
            progressDialog.close()
            xbmcgui.Dialog().notification(
                "Masterani Redux",
                "No hosts found for autoplay. Change addon settings and try again."
            )
            hostDialog = -1
        else:
            hostDialog = autoplayHost

    if hostDialog == -1:
        progressDialog.close()
        control.execute('dialog.close(okdialog)')
        return

    if 'true' in autoplay:
        try:
            hostname = autovids[hostDialog]['name']
            hostlink = autovids[hostDialog]['url']
            hostquality = autovids[hostDialog]['quality']
            embed_id = autovids[hostDialog]['embed_id']
        except:
            xbmcgui.Dialog().notification("Masterani Redux",
                                          "You have attempted all the hosts")
    else:
        hostname = videos[hostDialog]['name']
        hostlink = videos[hostDialog]['url']
        hostquality = videos[hostDialog]['quality']
        embed_id = videos[hostDialog]['embed_id']

    c = cache.get(masterani.get_anime_details, 3, anime_id)
    syn = c['plot'].encode('utf-8')
    print syn
    start_date = c['premiered']
    print start_date
    sty = c['premiered'].split("-", 1)[0]
    print sty
    gen = str(c['genre'])
    print gen
    epcount = c['episode_count']

    progressDialog.update(75, line1=l1, line3="Loading video.")

    #Resolve Links
    mp4 = getdirect(hostname, hostlink, hostquality, embed_id)
    progressDialog.close()
    MAPlayer().run(anime_id, ep_id, mp4, syn, start_date, sty, gen,
                   episode_number, epcount, episode_link)
Ejemplo n.º 6
0
def play(anime_id, episode_id):
    # try:
    # content = cache.get(masterani.get_anime_details(anime_id), 2)

    l1 = "Fetching video"
    progressDialog.create(heading="MasterAni", line1="Fetching video")
    progressDialog.update(0, line1=l1, line3="Loading hosts")
    hosts = client.request("http://www.masterani.me/api/hosts")

    if hosts is None:
        xbmcgui.Dialog().ok("Masterani", "Something went wrong.",
                            "Please try again later")
        return
    else:
        hosts = json.loads(hosts)

    # Remove Drive.g from list as it is not supported
    for e in hosts:
        # if 'Drive.g' in e['name']:
        #     hosts.remove(e)
        if 'Aika' in e['name']:
            hosts.remove(e)

    #remove all hosts that aren't enabled
    #probably not the best way to do this, but whatever, just trying to get it to work rn

    if control.setting("host.mp4upload") == "false":
        for e in hosts:
            if 'MP4Upload' in e['name']:
                hosts.remove(e)

    if control.setting("host.aniupload") == "false":
        for e in hosts:
            if 'Aniupload' in e['name']:
                hosts.remove(e)

    if control.setting("host.bakavide") == "false":
        for e in hosts:
            if 'Bakavideo' in e['name']:
                hosts.remove(e)

    if control.setting("host.youtube") == "false":
        for e in hosts:
            if 'Youtube' in e['name']:
                hosts.remove(e)

    if control.setting("host.beta") == "false":
        for e in hosts:
            if 'BETA' in e['name']:
                hosts.remove(e)

    if control.setting("host.stream.moe") == "false":
        for e in hosts:
            if 'Stream.moe' in e['name']:
                hosts.remove(e)

    if control.setting("host.drive.g") == "false":
        for e in hosts:
            if 'Drive.g' in e['name']:
                hosts.remove(e)

    if control.setting("host.vidstreaming") == "false":
        for e in hosts:
            if 'Vidstreaming' in e['name']:
                hosts.remove(e)

    if control.setting("host.rapidvideo") == "false":
        for e in hosts:
            if 'Rapidvideo' in e['name']:
                hosts.remove(e)

    if control.setting("host.tiwi.kiwi") == "false":
        for e in hosts:
            if 'Tiwi.kiwi' in e['name']:
                hosts.remove(e)

    if control.setting("host.streamango") == "false":
        for e in hosts:
            if 'Streamango' in e['name']:
                hosts.remove(e)

    if control.setting("host.openload") == "false":
        for e in hosts:
            if 'Openload' in e['name']:
                hosts.remove(e)

    progressDialog.update(25, line1=l1, line3="Loading episodes urls")

    videos = client.request("http://www.masterani.me/api/episode/%s?videos=1" %
                            episode_id)
    #the episode id api show all hosts (id) and the embed id of each video; host id is used to identify which host to select later
    videos = json.loads(videos)['videos']
    progressDialog.update(50, line1=l1, line3="Picking nose")

    hostlist = []

    videos = sorted(videos,
                    key=lambda k: (-int(k['type']), int(k['quality'])),
                    reverse=True)
    print videos
    autoplay = control.setting("autoplay.enabled")
    maxq = control.setting("autoplay.maxquality")
    subdub = control.setting("autoplay.subdub")

    hostCounter = 0
    autoplayHost = 0
    videoCounter = 0

    while videoCounter < len(videos):
        try:
            hostname = [
                x['name'] for x in hosts
                if int(x['id']) == int(videos[videoCounter]['host_id'])
            ][0]
            #just sort the videos by quality

            subs = 'Sub' if videos[videoCounter]['type'] is 1 else 'Dub'
            quality = videos[videoCounter]['quality']
            if 'true' in autoplay:
                if subdub == subs and int(quality) <= int(maxq):
                    hostlist.append("%s | %s | %s" % (quality, subs, hostname))
                    autoplayHost = hostCounter
                    #since in reverse order, the first one should be the best quality
                    #based on how this is written, autoplay wont automatically try the next host if this one fails
                    #might change it in the future
                    break
                hostCounter += 1
            else:
                hostlist.append("%s | %s | %s" % (quality, subs, hostname))
            videoCounter += 1
        except:
            videos.remove(videos[videoCounter])

    if len(hostlist) is 0:
        xbmcgui.Dialog().ok("Masterani", "No supported hosts found.")
        return

    if autoplay in 'false':
        hostdialog = control.dialog.select("Select host", hostlist)
    else:
        if len(hostlist) is 0:
            progressDialog.close()
            xbmcgui.Dialog().ok("Masterani", "No hosts found for autoplay.",
                                "Change addon settings and try again.")
            hostdialog = -1
        else:
            hostdialog = autoplayHost

    if hostdialog == -1:
        progressDialog.close()
        control.execute('Dialog.Close(okdialog)')
        return
    #choosing video from host id and embed id
    host_id = videos[hostdialog]['host_id']
    embed_id = videos[hostdialog]['embed_id']
    vidQuality = int(videos[hostdialog]['quality'])
    if host_id is '':
        return

    prefix = ""
    suffix = ""
    #each host has a prefix and suffix that makes the URL work, taken from the hosts api
    for host in hosts:
        if str(host_id) in str(host['id']):
            prefix = host['embed_prefix']
            suffix = host['embed_suffix']
            break

    try:
        if suffix is not None:
            url = prefix + embed_id + suffix
        else:
            url = prefix + embed_id
    except:
        pass

    print url
    progressDialog.update(75, line1=l1, line3="Loading video")
    #finds direct mp4 file on site (different methods depending on host)
    if 'moe' in host['name']:
        content = base64.b64decode(
            re.compile("atob\('(.+?)'\)").findall(client.request(url))[0])
        mp4 = re.compile("source src=\"(.+?)\"").findall(content)[0]
    if 'MP4Upload' in host['name']:
        www = re.compile("\|www([0-9]+?)\|").findall(client.request(url))[0]
        content = re.compile("\|mp4\|video\|(.+?)\|282\|").findall(
            client.request(url))
        if len(content) == 0:
            content = re.compile("\|mp4\|\|\|(.+?)\|282\|").findall(
                client.request(url))
        content = content[0]
        mp4 = "https://www" + www + ".mp4upload.com:282/d/" + content + "/video.mp4"
    if 'Bakavideo' in host['name']:
        content = re.compile("go\((.+?)\)").findall(client.request(url))[0]
        content = content.replace("'", "").replace(", ", "/")
        content = "https://bakavideo.tv/" + content
        content = client.request(content)
        content = json.loads(content)
        content = content['content']
        content = base64.b64decode(content)
        mp4s = client.parseDOM(content, 'source', ret='src')

        mp4 = ""
        for link in mp4s:
            if str(vidQuality) in link:
                mp4 = link

        if mp4 is "":
            mp4 = mp4s[0]

    if 'BETA' in host['name']:
        mp4 = embed_id
    #I think this has changed to Vidstreaming
    # if 'Vidstream' in host['name']:
    #     data = client.request(url)
    #     # mp4 = re.compile("source src='(.+?)'.+?" + str(quality) + "'/>").findall(data)[0]
    #     openload = re.compile("embedvideo\" src=\"(.+?)\"").findall(data)
    #
    #     if len(openload) > 0:
    #         openload = client.request(openload[0])
    #         try: import urlresolver
    #         except: pass
    #
    #         hmf = urlresolver.HostedMediaFile(openload[0])
    #         mp4 = hmf.resolve()
    #
    #         if mp4 is False:
    #             return
    #     else:
    #         mp4 = re.compile("source src='(.+?)'.+?" + str(quality) + "'/>").findall(data)
    #         if len(mp4) is 0:
    #             mp4 = re.compile("source src='(.+?)'").findall(data)[0]
    #         else:
    #             mp4 = mp4[0]
    #
    #     if 'googlevideo' in mp4:
    #         try: import urlresolver
    #         except: pass
    #         hmf = urlresolver.HostedMediaFile(mp4)
    #         mp4 = hmf.resolve()
    if 'Vidstreaming' in host['name']:
        mp4 = re.compile("file: '(.+?)',label").findall(client.request(url))[0]
    if 'Aniupload' in host['name']:
        mp4 = re.compile("\(\[\{src: \"(.+?)\"").findall(
            client.request(url))[0]

    if 'Openload' in host['name']:
        try:
            import urlresolver
        except:
            pass
        hmf = urlresolver.HostedMediaFile(url)
        mp4 = hmf.resolve()
    if 'Drive.g' in host['name']:
        mp4 = masterani.get_google_link(prefix + embed_id, vidQuality)
    if 'Rapidvideo' in host['name']:
        #Rapidvideo is a little weird in that there is only a single quality avavilble for selection
        #but in the player UI, there are a couple to choose from
        #it seems the code doesn't account for this and only allows the best quality available to be selected
        url = url + "&q=" + str(vidQuality) + "p"
        mp4 = re.compile("source src=\"(.+?)\"").findall(
            client.request(url))[0]
    if 'Tiwi.kiwi' in host['name']:
        #Tiwi kiwi seems to work basically none of the time now
        #Previously only some streams, now all stream seem to have seperate audio and video sources, in which case I'm not sure how to handle
        #I can get either the audio or video working but not both
        #The method below works if there is a single source for the video (which works [none of the times now])
        content = re.compile("\|mp4\|(.+?)\|sources\|").findall(
            client.request(url))[0]
        mp4 = "https://fs01.tiwicdn.net/" + content + "/v.mp4"
    if 'Streamango' in host['name']:
        #there's a different num and token for every request, so call once
        streamangoURL = client.request(url)
        #I had orginally thought that there was multiple links for different quality videos, but that doesn't seem to be the case
        numFinder = "',(.+?)\),height:"  # + str(vidQuality)
        num = re.compile(numFinder).findall(streamangoURL)[0]
        tokenFinder = "src:d\('(.+?)'," + str(
            num) + "\),height:"  #+ str(vidQuality)
        token = re.compile(tokenFinder).findall(streamangoURL)[0]
        mp4 = "https:" + streamangoFix.d(token, int(num))
    progressDialog.close()
    MAPlayer().run(anime_id, episode_id, mp4)