# -*- coding: utf-8 -*-
# vStream https://github.com/Kodi-vStream/venom-xbmc-addons

from lib.comaddon import VSlog
from lib.parser import cParser
from lib.handler.requestHandler import cRequestHandler

class cHosterHandler:

    def getUrl(self, oHoster):
        sUrl = oHoster.getUrl()
        VSlog("hosterhandler " + sUrl)
        oRequest = cRequestHandler(sUrl)
        sContent = oRequest.request()

        aMediaLink = cParser().parse(sContent, oHoster.getPattern())
        if (aMediaLink[0] == True):
            return True, aMediaLink[1][0]
        return False, ''

    def getHoster(self, sHosterFileName):
        exec("from extractors." + sHosterFileName + " import cHoster")

        return cHoster()
