Exemple #1
0
def get_links(url):
    orig_title = xbmc.getInfoLabel('ListItem.Title')
    html = url_utils.GetURL(url)
    html = html.split('>ENGLISH<')[-1]
    links = common.parseDOM(html, "iframe", ret="src")
    lnks = common.parseDOM(html, "a", ret="href")
    links = links + lnks
    for i, link in enumerate(links):
        if 'mail.ru/vid' in link:
            link = link.replace(
                'https://videoapi.my.mail.ru/videos/embed/mail/',
                'https://my.mail.ru/+/video/meta/')
            link = link.replace('https://my.mail.ru/video/embed/',
                                'https://my.mail.ru/+/video/meta/')
            link = link.replace('html', 'json')
            cookieJar = cookielib.CookieJar()
            opener = urllib2.build_opener(
                urllib2.HTTPCookieProcessor(cookieJar), urllib2.HTTPHandler())
            conn = urllib2.Request(link)
            connection = opener.open(conn)
            f = connection.read()
            connection.close()
            js = json.loads(f)
            for cookie in cookieJar:
                token = cookie.value
            js = js['videos']
            for el in js:
                basemenu.addDirectLink(
                    'mail.ru - ' + el['key'], {'Title': orig_title},
                    'https:' + el['url'] + '|Cookie=video_key=' + token)
        elif 'openload.co' in link:
            basemenu.addLink('openload', orig_title, link, mode="play")
    xbmcplugin.endOfDirectory(int(sys.argv[1]), cacheToDisc=True)
Exemple #2
0
def resolve_nhl(url):
    try:
        url = url.split("playlist=")[-1]
        url = 'http://video.nhl.com/videocenter/servlets/playlist?ids=%s&format=json' % url
        result = url_utils.GetURL(url)
        url = re.compile('"publishPoint":"(.+?)"').findall(result)[0]
        return url
    except:
        return
Exemple #3
0
def resolve(url):
    try:
        result = url_utils.GetURL(url)
        result = result.replace('\n','')
        result = re.sub(r'<script.+?</script>', '', result, flags=re.DOTALL)
        
        try:
            url = re.search("data-config\s*=\s*(?:\'|\")(.+?)(?:\'|\")", result).groups()[0]
        except:    
            url = common.parseDOM(result, "iframe", ret="src")[0]
            
        if '=http' in url: url = re.search("=(https?://.+)", url).groups()[0]
        elif url.startswith("//"): url = 'http:%s' % url
        
        if 'video.nhl.com' in url: url = resolve_nhl(url)
        else: url = HostedMediaFile(url=url).resolve()
        return url
    except:
        return
Exemple #4
0
def get_games(page, mode):
    if mode == 'nhllife2sport':
        url = 'http://www.life2sport.com/category/online-video/hockey/nhl/page/' + str(
            page)
    elif mode == 'nbalife2sport':
        url = 'http://www.life2sport.com/category/online-video/basketbol/nba/page/' + str(
            page)
    elif mode == 'nfllife2sport':
        url = 'http://www.life2sport.com/category/online-video/american-football/page/' + str(
            page)
    elif mode == 'mlblife2sport':
        url = 'http://www.life2sport.com/category/online-video/mlb/page/' + str(
            page)
    log_utils.log('Page: ' + str(page) + ' / Mode: ' + str(mode) + ' / URL: ' +
                  url)
    html = url_utils.GetURL(url)
    links = common.parseDOM(html, "a", attrs={"rel": "bookmark"}, ret="href")
    if links:
        del links[1::2]
    for i, el in enumerate(links):
        log_utils.log('Link: ' + el)
        #        try:
        found_match = False
        if mode == 'nbalife2sport':
            for word in NBAL2SWordList:
                if word in el:
                    found_match = True
        if '-nfl-' in el or '-nfl.' in el or '-nhl-' in el or '-nhl.' in el or '-mlb-' in el or found_match:
            title = common.parseDOM(html, "a", attrs={"href": el},
                                    ret="title")[0]
            title = url_utils.strip_non_ascii(title)
            log_utils.log('Title Check: ' + title)
            title = title.replace('&#8211;', '@').strip()
            titles = title.split('/')
            season = ''
            gameday = ''
            loop_check = 0
            for tit in titles:
                log_utils.log('Title Loop Check: ' + tit)
                if len(tit) > 25:
                    title = tit
                if mode == 'nhllife2sport':
                    if loop_check == 2:
                        log_utils.log('Season Loop Check: ' + tit.strip())
                        season = '[COLOR yellow]' + tit.strip() + '[/COLOR]'
                    elif loop_check == 3:
                        log_utils.log('Gameday Loop Check: ' + tit.strip())
                        tit = tit[:-4]
                        gameday = '[COLOR yellow]' + tit.strip() + '[/COLOR] '
                elif mode == 'nfllife2sport':
                    if loop_check == 2:
                        log_utils.log('Season Loop Check: ' + tit.strip())
                        season = '[COLOR yellow]' + tit.strip() + '[/COLOR]'
                    elif loop_check == 3:
                        log_utils.log('Gameday Loop Check: ' + tit.strip())
                        gameday = '[COLOR yellow]' + tit.strip() + '[/COLOR] '
                elif mode == 'nbalife2sport':
                    if loop_check == 2:
                        log_utils.log('Season Loop Check: ' + tit.strip())
                        season = '[COLOR yellow]' + tit.strip() + '[/COLOR]'
                    elif loop_check == 4:
                        log_utils.log('Gameday Loop Check: ' + tit.strip())
                        gameday = '[COLOR yellow]' + tit.strip(
                        )[:10] + '[/COLOR] '
                elif mode == 'mlblife2sport':
                    if loop_check == 2:
                        log_utils.log('Season Loop Check: ' + tit.strip())
                        season = '[COLOR yellow]' + tit.strip() + '[/COLOR]'
                    elif loop_check == 3:
                        log_utils.log('Game or Post Season Loop Check: ' +
                                      tit.strip())
                        if 'game' in tit.strip().lower():
                            season = season + '[COLOR green] ' + tit.strip(
                            ) + '[/COLOR]'
                    elif loop_check == 4:
                        log_utils.log('World Series or Date Loop Check: ' +
                                      tit.strip())
                        if 'series' in tit.strip().lower():
                            season = season + '[COLOR green] ' + tit.strip(
                            ) + '[/COLOR]'
                        else:
                            gameday = '[COLOR yellow]' + tit.strip(
                            )[:10] + '[/COLOR] '
                    elif loop_check == 5:
                        log_utils.log('Game of World Series Loop Check: ' +
                                      tit.strip())
                        season = season + '[COLOR green] ' + tit.strip(
                        ) + '[/COLOR]'
                    elif loop_check == 6:
                        log_utils.log('Gameday Loop Check: ' + tit.strip())
                        gameday = '[COLOR yellow]' + tit.strip(
                        )[:10] + '[/COLOR] '
                loop_check = loop_check + 1
            title = gameday + title + season
            basemenu.addStreamFolder(title,
                                     el,
                                     iconImg=LOGOS[mode[0:3]],
                                     mode="playlife2sportarchive")
#        except:
#            log_utils.log('Exception with Link: ' + el)
#            pass
    uri = sys.argv[0] + '?mode=%s&page=%s' % (mode, str(int(page) + 1))
    item = xbmcgui.ListItem("next page...", iconImage='', thumbnailImage='')
    xbmcplugin.addDirectoryItem(int(sys.argv[1]), uri, item, True)
    xbmcplugin.endOfDirectory(int(sys.argv[1]), cacheToDisc=True)
Exemple #5
0
def get_games(url):
    log_utils.log('LiveTV.SX: get_games - URL: ' + str(url))
    try:
        result = url_utils.GetURL(url)
        result = result.decode('iso-8859-1').encode('utf-8')
        result = result.replace('\n','')
        videos = common.parseDOM(result, "table", attrs = { "height": "27" })
    except:
        log_utils.log('LiveTV.SX: get_games - GetURL Exception')
        return

    videoList = []
    log_utils.log('LiveTV.SX: get_games - Videos Count: ' + str(len(videos)))
    for video in videos:
        try:
            title = re.compile('<b>(.+?)</b>').findall(video)
            title = [i for i in title if '&ndash;' in i or '-' in i][-1]
            title = title.split('<b>')[-1]
            title = title.replace('&ndash;', '-')
            title = common.replaceHTMLCodes(title)
            title = title.encode('utf-8')
            log_utils.log('LiveTV.SX: get_games - Title: ' + str(title))

            dateDict = {'January': '01', 'February': '02', 'March': '03', 'April': '04', 'May': '05', 'June': '06', 'July': '07', 'August': '08', 'September': '09', 'October': '10', 'November': '11', 'December' : '12'}

            try:
                date = common.parseDOM(video, "span", attrs = { "class": "date" })[0]
                date = re.findall('(\d+)[.](\d+)[.](\d+)', date, re.I)[0]
                date = '%s-%s-%s' % ('20' + '%02d' % int(date[2]), '%02d' % int(date[1]), '%02d' % int(date[0]))
                log_utils.log('LiveTV.SX: get_games - Date: ' + str(date))
            except:
                year = common.parseDOM(result, "a", attrs = { "class": "mwhite" })
                year = [i for i in year if i.isdigit()][0]
                date = result.split(video.encode('utf-8'))[0]
                date = date.split('#2862a8')[-1]
                date = re.compile('<b>(\d+?)\s(.+?),\s.+?</b>').findall(date)[0]
                date = '%s-%s-%s' % (year, dateDict[date[1]], '%02d' % int(date[0]))
                log_utils.log('LiveTV.SX: get_games - Date Exception: ' + str(date))
            
            name = '[COLOR=yellow]%s[/COLOR] %s' % (date, title)
            name = common.replaceHTMLCodes(name)
            name = name.encode('utf-8')
            log_utils.log('LiveTV.SX: get_games - Name: ' + str(name))

            u = [('Full match record', ''), ('First Half', ' (1)'), ('Second Half', ' (2)'), ('First Period', ' (1)'), ('Second Period', ' (2)'), ('Third Period', ' (3)'), ('Fourth Period', ' (4)'), ('First Part', ' (1)'), ('Second Part', ' (2)'), ('Third Part', ' (3)'), ('Fourth Part', ' (4)')]
            uDict, uList = dict(u), [i[0] for i in u]
            u = re.compile('href="(.+?)">(.+?)<').findall(video)
            u = [i for i in u if i[1] in uList]
            u.sort(key=lambda x: uList.index(x[1]))
            url =  livetv_base + u[0][0]
            if len(url) == 0: raise Exception()
            type = 'games'

            url = url.encode('utf-8')
            log_utils.log('LiveTV.SX: get_games - url: ' + str(url))

            videoList.append({'name': name, 'url': url, 'date': date, 'genre': 'Sports', 'title': title, 'type': type})
        except:
            log_utils.log('LiveTV.SX: get_games - Videos Loop Exception')
            pass
    
    try:
        videoList = [i for n,i in enumerate(videoList) if i not in videoList[:n]]
        videoList = sorted(videoList, key=itemgetter('date'))
        videoList = videoList[::-1]
    except:
        pass

    if videoList == None or len(videoList) == 0: return

    total = len(videoList)
    log_utils.log('LiveTV.SX: get_games - videoList Count: ' + str(total))
    basemenu.addSectionItem('[COLOR=limegreen]Streams May Require Pairing[/COLOR]', '', '')
    for i in videoList:
        try:
            basemenu.addLink(i['name'], i['name'], i['url'], mode="play")
        except:
            pass

    xbmcplugin.endOfDirectory(int(sys.argv[1]), cacheToDisc=True)