Exemplo n.º 1
0
def getChannelGuideUrl(tvchannel):
    url = 'https://www.cinemagia.ro/program-tv/'

    try:
        req = urllib2.Request(url)
        req.add_header('User-Agent', common.HEADERS['User-Agent'])
        conn = urllib2.urlopen(req, timeout=5)
        html = conn.read()
        conn.close()

        urls = parseDOM(html, 'a', attrs={'class': 'station-link'}, ret='href')
        names = parseDOM(html, 'a', attrs={'class': 'station-link'})

        seq2 = tvchannel.lower().replace(' ', '').strip()

        seqm = SequenceMatcher()
        seqm.set_seq2(seq2)

        ratio_list = []

        for name in names:
            seq1 = name.lower().replace(' ', '').strip()
            seqm.set_seq1(seq1)
            ratio = seqm.ratio()
            ratio_list.append(ratio)

        ratio_max_index = max(xrange(len(ratio_list)),
                              key=ratio_list.__getitem__)

        return urls[ratio_max_index]

    except:
        log_utils.log(traceback.print_exc())

    return None
Exemplo n.º 2
0
def getChannelGuideUrl(tvchannel):
    url = 'https://www.cinemagia.ro/program-tv/'
    
    try:
        req = urllib2.Request(url)
        req.add_header('User-Agent', common.HEADERS['User-Agent'])
        conn = urllib2.urlopen(req, timeout=5)
        html = conn.read()
        conn.close()
        
        urls = parseDOM(html, 'a', attrs={'class': 'station-link'}, ret='href')
        names = parseDOM(html, 'a', attrs={'class': 'station-link'})
        
        seq2 = tvchannel.lower().replace(' ', '').strip()
        
        seqm = SequenceMatcher()
        seqm.set_seq2(seq2)
        
        ratio_list = []
        
        for name in names:
            seq1 = name.lower().replace(' ', '').strip()
            seqm.set_seq1(seq1)
            ratio = seqm.ratio()
            ratio_list.append(ratio)
        
        ratio_max_index = max(xrange(len(ratio_list)), key=ratio_list.__getitem__)
        
        return urls[ratio_max_index]
    
    except:
        log_utils.log(traceback.print_exc())
    
    return None
Exemplo n.º 3
0
def getAccountInfo():
    try:
        html = _getHtml()
        
        div = parseDOM(html, 'div', attrs={'id': 'messageDiv'})[0]
        
        if 'expirat' in div:
            return 'Abonamentul a expirat'
        
        m = re.search(r'Abonamentul este.+?inclusiv\)', div, re.DOTALL)
        
        if m:
            return m.group(0).encode('utf-8')
        
    except:
        log_utils.log(traceback.print_exc())
    
    return None
Exemplo n.º 4
0
def getTVChannelsList():
    lst = []
    
    try:
        html = _getHtml()
        
        ul = parseDOM(html, 'ul', attrs={'class': 'sc_menu'})[0]
        
        results = re.findall(r'playFlowRtmpE\(\'(.+?)\'\).+?<img src="(.+?)".+?<a href.+?>(.+?)<\/a>', ul)
        
        for id, img, name in results:
            tv = {}
            tv['id'] = id.strip().encode('utf-8')
            tv['img'] = img.strip().encode('utf-8')
            tv['name'] = formatTVChannelName(name.strip().encode('utf-8'))
            lst.append(tv)
    except:
        log_utils.log(traceback.print_exc())
    
    return lst