Пример #1
0
    def __init__(self):
        self.id = 'plugin.video.mrstealth.serialu.net'
        self.addon = xbmcaddon.Addon(self.id)
        self.icon = self.addon.getAddonInfo('icon')
        self.path = self.addon.getAddonInfo('path')
        self.profile = self.addon.getAddonInfo('profile')

        self.language = self.addon.getLocalizedString
        self.handle = int(sys.argv[1])
        self.url = 'http://serialu.net'

        self.favorites = MyFavorites(self.id)
        self.inext = os.path.join(self.path, 'resources/icons/next.png')
Пример #2
0
    def __init__(self):
        self.id = 'plugin.video.online-life.ru'
        self.addon = xbmcaddon.Addon(self.id)
        self.icon = self.addon.getAddonInfo('icon')
        self.path = self.addon.getAddonInfo('path')
        self.profile = self.addon.getAddonInfo('profile')

        self.language = self.addon.getLocalizedString
        self.handle = int(sys.argv[1])
        self.url = 'http://www.online-life.ru'

        self.favorites = MyFavorites(self.id)

        self.inext = os.path.join(self.path, 'resources/icons/next.png')
        self.debug = False
Пример #3
0
class SerialuNet():
    def __init__(self):
        self.id = 'plugin.video.mrstealth.serialu.net'
        self.addon = xbmcaddon.Addon(self.id)
        self.icon = self.addon.getAddonInfo('icon')
        self.path = self.addon.getAddonInfo('path')
        self.profile = self.addon.getAddonInfo('profile')

        self.language = self.addon.getLocalizedString
        self.handle = int(sys.argv[1])
        self.url = 'http://serialu.net'

        self.favorites = MyFavorites(self.id)
        self.inext = os.path.join(self.path, 'resources/icons/next.png')

    def main(self):
        params = common.getParameters(sys.argv[2])
        mode = url = page = None

        mode = params['mode'] if 'mode' in params else None
        url = urllib.unquote_plus(params['url']) if 'url' in params else None
        page = params['page'] if 'page' in params else 1

        if mode == 'play':
            self.playItem(url)
        if mode == 'search':
            self.search()
        if mode == 'genres':
            self.listGenres(url)
        if mode == 'show':
            self.getFilmInfo(url)
        if mode == 'category':
            self.getCategoryItems(url, page)
        if mode == 'favorites':
            self.show_favorites()
        elif mode is None:
            self.menu()

    def menu(self):
        uri = sys.argv[0] + '?mode=%s&url=%s' % ("search", self.url)
        item = xbmcgui.ListItem("[B][COLOR=FF00FF00]%s[/COLOR][/B]" % self.language(2000), thumbnailImage=self.icon)
        xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

        self.favorites.ListItem()

        uri = sys.argv[0] + '?mode=%s&url=%s' % ("genres", self.url)
        item = xbmcgui.ListItem("[B][COLOR=FF00FFF0]%s[/COLOR][/B]" % self.language(1000), thumbnailImage=self.icon)
        xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

        self.getCategoryItems(self.url, 1)
        xbmcplugin.endOfDirectory(self.handle, True)

    def getCategoryItems(self, url, page):
        print "*** Get category items for page: %s and url: %s" % (page, url)

        # Search workaround
        if '?s=' in url:
            tmp = url.split('?s=')
            if page == 1:
                page_url = "%s/page/%s/?s=%s" % (self.url, str(int(page)), tmp[1])
            else:
                page_url = "%s/page/%s/?s=%s" % (self.url, str(int(page)), urllib.quote(tmp[1]))
        else:
            print "No search in url"
            if page == 1:
                page_url = url
            else:
                page_url = "%s/page/%s/" % (url, str(int(page)))

        print "Page URL: %s" % page_url

        response = self.get(page_url)
        items = 0

        if response:
            container = common.parseDOM(response, "div", attrs={"id": "column"})
            posts = common.parseDOM(container, "div", attrs={"class": "post"})

            header = common.parseDOM(posts, "h2")
            content = common.parseDOM(posts, 'div', attrs={"class": "content"})


            links = common.parseDOM(header, "a", ret="href")
            titles = common.parseDOM(header, "a")
            images = common.parseDOM(content, "img", ret="src")

            for i, title in enumerate(titles):
                items += 1

                cat = common.parseDOM(posts[i], "div", attrs={'class': 'cat'})
                genres = common.parseDOM(cat, 'a', attrs={'rel': 'category tag'})

                infos = common.parseDOM(content[i], "p")
                desc = infos[3]

                for j, info in enumerate(infos):
                    if 'strong' in info:
                        desc = common.stripTags(info)
                        genre = ', '.join(genres)

                link = links[i]
                image = images[i]

                uri = sys.argv[0] + '?mode=show&url=%s' % link
                item = xbmcgui.ListItem(title, thumbnailImage=image)
                item.setInfo(type='Video', infoLabels={'title': title, 'genre': genre, 'plot': self.unescape(desc)})

                self.favorites.addContextMenuItem(item, {'title': title.encode('utf-8'), 'url': link, 'image': image, 'playable': False, 'action': 'add', 'plugin': self.id})

                xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

        else:
            self.showErrorMessage("getCategoryItems(): Bad response status%s" % response["status"])

        if not items < 8:
            uri = sys.argv[0] + '?mode=%s&url=%s&page=%s' % ("category", url, str(int(page) + 1))
            item = xbmcgui.ListItem(self.language(9001), thumbnailImage=self.inext)
            xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

        xbmc.executebuiltin('Container.SetViewMode(52)')
        xbmcplugin.endOfDirectory(self.handle, True)

    def getFilmInfo(self, url):
        print "*** getFilmInfo rot URL %s" % url

        response = common.fetchPage({"link": url})
        entry = common.parseDOM(response["content"], 'div', attrs={'class': 'entry'})

        flash_player = common.parseDOM(entry, "object")
        image = common.parseDOM(entry, 'img', attrs={'class': 'm_pic'}, ret='src')[0]

        uhash = common.parseDOM(flash_player, "param", attrs={"name": "flashvars"}, ret="pl")[0].split('&')[0]
        uhash = uhash.replace('"', '')

        # 1) get encoded URL from playlist/file HASH
        uppod_url = uppod.decodeSourceURL(uhash)

        # 2) get source HASH from encoded URL => getDecodedHashFromSourceURL(url, referer)
        uppod_hash = uppod.getDecodedHashFromSourceURL(uppod_url, 'http://serialu.net/media/stil-nov/uppod.swf')

        # http://serialu.net/una1.php?s=I.Hear.Your.Voice&md5=5de21a077941aaafd46e803be2a0de89&rand=0.16188193298876286

        # 3) get playlist/file from encoded HASH
        json_playlist = json.loads(uppod.decode(uppod_hash).encode('latin1').decode('utf-8'))
        playlist = json_playlist['playlist']

        if 'playlist' in playlist[0]:
            print "*** This is a playlist with several seasons"

            for season in playlist:
                episods = season['playlist']

                for episode in episods:
                    title = episode['comment']
                    uri = sys.argv[0] + '?mode=play&url=%s' % uppod.decode(episode['file'])
                    info = {'title': title, 'overlay': xbmcgui.ICON_OVERLAY_WATCHED, 'playCount': 0}

                    item = xbmcgui.ListItem(title, thumbnailImage=image)
                    item.setInfo(type='Video', infoLabels=info)
                    item.setProperty('IsPlayable', 'true')
                    xbmcplugin.addDirectoryItem(self.handle, uri, item, False)
        else:
            print "*** This is a playlist with one season"

            for episode in playlist:
                title = episode['comment']
                uri = sys.argv[0] + '?mode=play&url=%s' % uppod.decode(episode['file'])
                info = {'title': title, 'overlay': xbmcgui.ICON_OVERLAY_WATCHED, 'playCount': 0}

                item = xbmcgui.ListItem(title, thumbnailImage=image)
                item.setInfo(type='Video', infoLabels=info)
                item.setProperty('IsPlayable', 'true')
                xbmcplugin.addDirectoryItem(self.handle, uri, item, False)

        xbmc.executebuiltin('Container.SetViewMode(51)')
        xbmcplugin.endOfDirectory(self.handle, True)

    def listGenres(self, url):
        print "list genres"
        #response = common.fetchPage({"link": url})
        response = self.get(url)

        container = common.parseDOM(response, "div", attrs={"class": "main-container"})
        genres = common.parseDOM(container, "ul", attrs={"class": "h-menu2"})

        titles = common.parseDOM(genres, "a")
        links = common.parseDOM(genres, "a", ret="href")

        print links

        for i, title in enumerate(titles):
            uri = sys.argv[0] + '?mode=category&url=%s' % links[i]
            item = xbmcgui.ListItem(title, thumbnailImage=self.icon)
            xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

        xbmcplugin.endOfDirectory(self.handle, True)

    def playItem(self, url):
        print "*** play url %s" % url
        item = xbmcgui.ListItem(path=url)
        xbmcplugin.setResolvedUrl(self.handle, True, item)

    def get(self, url):
        cj = cookielib.LWPCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
        urllib2.install_opener(opener)

        request = urllib2.Request(url)
        request.add_header('Host', 'serialu.net')
        request.add_header('User-Agent', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.13 (KHTML, like Gecko) Chrome/24.0.1290.0 Safari/537.13 SUSE/24.0.1290.0')

        response = opener.open(request)
        return response.read()

    def show_favorites(self):
        self.favorites.list()
        xbmcplugin.endOfDirectory(self.handle, True)

    def search(self):
        kbd = xbmc.Keyboard()
        kbd.setDefault('')
        kbd.setHeading(self.language(2000))
        kbd.doModal()
        keyword = ''

        if kbd.isConfirmed():
            if self.addon.getSetting('translit') == 'true':
                keyword = translit.rus(kbd.getText())
            else:
                keyword = kbd.getText()

            serach_url = "%s?s=%s" % (self.url, urllib.quote(keyword))
            self.getCategoryItems(serach_url, 1)
        else:
            self.menu()

    def showErrorMessage(self, msg):
        print msg
        xbmc.executebuiltin("XBMC.Notification(%s,%s, %s)" % ("ERROR", msg, str(10 * 1000)))

    def unescape(self, string):
        return HTMLParser.HTMLParser().unescape(string) #.decode('cp1251')

    def encode(self, string):
        return string.decode('cp1251').encode('utf-8')
Пример #4
0
class OnlineLife():
    def __init__(self):
        self.id = 'plugin.video.online-life.ru'
        self.addon = xbmcaddon.Addon(self.id)
        self.icon = self.addon.getAddonInfo('icon')
        self.path = self.addon.getAddonInfo('path')
        self.profile = self.addon.getAddonInfo('profile')

        self.language = self.addon.getLocalizedString
        self.handle = int(sys.argv[1])
        self.url = 'http://www.online-life.ru'

        self.favorites = MyFavorites(self.id)

        self.inext = os.path.join(self.path, 'resources/icons/next.png')
        self.debug = False

    def main(self):
        params = common.getParameters(sys.argv[2])
        mode = url = page = None

        mode = params['mode'] if 'mode' in params else None
        url = urllib.unquote_plus(params['url']) if 'url' in params else None
        page = params['page'] if 'page' in params else 1

        keyword = params['keyword'] if 'keyword' in params else None
        unified = params['unified'] if 'unified' in params else None

        if mode == 'play':
            self.play(url)
        if mode == 'search':
            self.search(keyword, unified)
        if mode == 'genres':
            self.listGenres(url)
        if mode == 'show':
            self.getFilmInfo(url)
        if mode == 'category':
            self.getCategoryItems(url, page)
        if mode == 'favorites':
            self.show_favorites()
        elif mode is None:
            self.menu()

    def menu(self):
        uri = sys.argv[0] + '?mode=%s&url=%s' % ("search", self.url)
        item = xbmcgui.ListItem("[B][COLOR=FF00FF00]%s[/COLOR][/B]" % self.language(2000), thumbnailImage=self.icon)
        xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

        self.favorites.ListItem()

        uri = sys.argv[0] + '?mode=%s&url=%s' % ("genres", self.url)
        item = xbmcgui.ListItem("[B][COLOR=FF00FFF0]%s[/COLOR][/B]" % self.language(1000), thumbnailImage=self.icon)
        xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

        uri = sys.argv[0] + '?mode=%s&url=%s' % ("category", "http://www.online-life.ru/kino-multserial/")
        item = xbmcgui.ListItem("[B][COLOR=FF00FFF0]%s[/COLOR][/B]" % self.language(1004), thumbnailImage=self.icon)
        xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

        self.getCategoryItems(self.url, 0)
        xbmcplugin.endOfDirectory(self.handle, True)

    def getCategoryItems(self, url, page):
        page_url = self.url if page == 0 else "%s/page/%s/" % (url, str(int(page)))
        response = common.fetchPage({"link": page_url})

        if response["status"] == 200:
            container = common.parseDOM(response["content"], "div", attrs={"id": "container"})
            posts = common.parseDOM(container, "div", attrs={"class": "custom-post media-grid"})
            extras = common.parseDOM(container, "div", attrs={"class": "extra"})
            pagenav = common.parseDOM(container, "div", attrs={"class": "navigation"})

            ratings = common.parseDOM(container, "li", attrs={"class": "current-rating"})
            items = 0

            for i, post in enumerate(posts):
                items += 1

                poster = common.parseDOM(post, "div", attrs={"class": "custom-poster"})
                media_data = common.parseDOM(extras[i], "div", attrs={"class": "media-data text-overflow"})

                title = self.encode(common.stripTags(common.parseDOM(poster, "a")[0]))
                link = common.parseDOM(poster, "a", ret="href")[0]
                image = common.parseDOM(poster, "img", ret="src")[0]

                description = self.encode(common.stripTags(common.parseDOM(extras[i], "div", attrs={"class": "description"})[0]))
                genres = self.encode(', '.join(common.parseDOM(media_data, "a")))

                rating = float(ratings[i]) / 10

                uri = sys.argv[0] + '?mode=show&url=%s' % link
                item = xbmcgui.ListItem(title, thumbnailImage=image)
                item.setInfo(type='Video', infoLabels={'title': title, 'genre': genres, 'plot': description, 'rating': rating})

                self.favorites.addContextMenuItem(item, {'title': title, 'url': link, 'image': image, 'playable': False, 'action': 'add', 'plugin': self.id})

                xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

            if pagenav and not items < 20:
                uri = sys.argv[0] + '?mode=%s&url=%s&page=%s' % ("category", url, str(int(page) + 1))
                item = xbmcgui.ListItem(self.language(9001), thumbnailImage=self.inext)
                xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

        else:
            self.showErrorMessage("getCategoryItems(): Bad response status%s" % response["status"])

        xbmc.executebuiltin('Container.SetViewMode(52)')
        xbmcplugin.endOfDirectory(self.handle, True)

    def getFilmInfo(self, url):
        response = common.fetchPage({"link": url})

        content = common.parseDOM(response["content"], "div", attrs={"id": "dle-content"})
        story = common.parseDOM(response["content"], "div", attrs={"class": "full-story"})

        title = self.encode(common.parseDOM(story, "span", attrs={"itemprop": "name"})[0])
        image = common.parseDOM(story, "img", attrs={"itemprop": "image"}, ret="src")[0]

        scripts = common.parseDOM(content, "script", attrs={"type": "text/javascript"})

        itemprop_genre = common.parseDOM(story, "span", attrs={"itemprop": "genre"})
        genres = self.encode(', '.join(common.parseDOM(itemprop_genre, 'a')))

        desc = self.encode(common.parseDOM(story, "div", attrs={"style": "display:inline;"})[0])

        parser = URLParser()

        #for i, script in enumerate(scripts):
        #    print "%d #########" % i
        #    print script

        try:
            link = parser.parse(scripts[6])[0]
        except IndexError:
            link = parser.parse(scripts[7])[0]

        movie = link if not link.endswith('.txt') else None
        season = link if link.endswith('.txt') else None

        if movie:
            uri = sys.argv[0] + '?mode=play&url=%s' % urllib.quote_plus(movie)

            item = xbmcgui.ListItem(title, thumbnailImage=image)
            item.setInfo(type='Video', infoLabels={'title': title, 'genre': genres, 'plot': common.stripTags(desc), 'overlay': xbmcgui.ICON_OVERLAY_WATCHED, 'playCount': 0})
            item.setProperty('IsPlayable', 'true')

            xbmcplugin.addDirectoryItem(self.handle, uri, item, False)
            xbmc.executebuiltin('Container.SetViewMode(52)')

        elif season:
            print "This is a season %s" % season
            response = common.fetchPage({"link": season})

            if response["status"] == 200:
                response = eval(response["content"].replace('\t', '').replace('\r\n', ''))

                if 'playlist' in response['playlist'][0]:
                    print "This is a season multiple seasons"

                    for season in response['playlist']:
                        episods = season['playlist']

                        for episode in episods:
                            etitle = "%s (%s)" % (episode['comment'], common.stripTags(season['comment']))
                            url = episode['file']

                            # print "**** %s" % url

                            uri = sys.argv[0] + '?mode=play&url=%s' % urllib.quote_plus(url)
                            item = xbmcgui.ListItem(etitle, thumbnailImage=image)

                            labels = {'title': title, 'genre': 'genre', 'plot': 'desc', 'overlay': xbmcgui.ICON_OVERLAY_WATCHED, 'playCount': 0}
                            item.setInfo(type='Video', infoLabels=labels)

                            item.setProperty('IsPlayable', 'true')
                            xbmcplugin.addDirectoryItem(self.handle, uri, item, False)
                    xbmc.executebuiltin('Container.SetViewMode(51)')

                else:
                    print "This is one season"
                    for episode in response['playlist']:
                        etitle = episode['comment']
                        url = episode['file']

                        uri = sys.argv[0] + '?mode=play&url=%s' % urllib.quote_plus(url)
                        item = xbmcgui.ListItem(etitle, thumbnailImage=image)

                        labels = {'title': title, 'genre': 'genre', 'plot': 'desc', 'overlay': xbmcgui.ICON_OVERLAY_WATCHED, 'playCount': 0}

                        item.setInfo(type='Video', infoLabels=labels)
                        item.setProperty('IsPlayable', 'true')
                        xbmcplugin.addDirectoryItem(self.handle, uri, item, False)
                    xbmc.executebuiltin('Container.SetViewMode(51)')

        xbmcplugin.endOfDirectory(self.handle, True)

    def listGenres(self, url):
        response = common.fetchPage({"link": url})

        container = common.parseDOM(response["content"], "div", attrs={"class": "nav"})
        titles = common.parseDOM(container, "a", attrs={"class": "link1"})
        links = common.parseDOM(container, "a", attrs={"class": "link1"}, ret="href")

        uri = sys.argv[0] + '?mode=category&url=%s' % "http://www.online-life.ru/kino-new/"
        item = xbmcgui.ListItem(self.language(1007), thumbnailImage=self.icon)
        xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

        for i, title in enumerate(titles):
            link = links[i] if links[i].startswith('http') else self.url + links[i]
            uri = sys.argv[0] + '?mode=category&url=%s' % link
            item = xbmcgui.ListItem(self.encode(title), thumbnailImage=self.icon)
            xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

        uri = sys.argv[0] + '?mode=category&url=%s' % "http://www.online-life.ru/kino-tv/"
        item = xbmcgui.ListItem(self.language(1006), thumbnailImage=self.icon)
        xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

        xbmcplugin.endOfDirectory(self.handle, True)

    def show_favorites(self):
        self.favorites.list()
        xbmcplugin.endOfDirectory(self.handle, True)

    def play(self, url):
        print "Play media URL: %s" % url

        hd = True if  self.addon.getSetting('hd_youtube_videos') == 'true' else False
        supported_resolutions = ['720p', '1080p'] if hd else ['360p', '480p']
        video_url = ''

        try:
            if 'youtube' in url:
                # url =  youtube.get_youtube_url(url, hd) if 'youtube' in url else url
                yt.url = url
                video_url = yt.videos[-1].url
                # for video in yt.videos:
                #     extension = video.__dict__['extension']
                #     resolution = video.__dict__['resolution']

                #     if resolution in supported_resolutions and extension == 'mp4':
                #         # print "%s %s" % (video.extension, video.resolution)
                #         video_url = yt.videos[0].url
                #     else:
                #         print "Unsupported resolution or video format: %s %s" % (resolution, extension)
            else:
                video_url = url

            print urllib.unquote(video_url)
            item = xbmcgui.ListItem(path=video_url)
            xbmcplugin.setResolvedUrl(self.handle, True, item)
        except Exception, e:
            self.showErrorMessage(e)