Exemple #1
0
    def read(self):
        if not os.path.exists(self.session_file_location):
            return []

        tempitems = []
        config = ConfigParser.ConfigParser()
        config.read(self.session_file_location)
        section_list = config.sections()
        for section in section_list:
            try:
                index = int(section.strip("session_video_"))
            except ValueError as exception:
                print >> sys.stderr, "Session \"%s\" has invalid identifier" % section
                continue

            try:
                page_url = config.get(section, "page_url")
                youtube_video = parser_manager.validateURL(page_url)
                if not youtube_video:
                    continue

                title = config.get(section, "title")
                youtube_video.setTitle(title)
                real_url = config.get(section, "real_url")
                youtube_video.setRealUrl(real_url)
                flv_file = config.get(section, "flv_file")
                youtube_video.setFlvFile(flv_file)
                avi_file = config.get(section, "avi_file")
                youtube_video.setOutputFile(avi_file)
                file_format = config.getint(section, "file_format")
                youtube_video.setFileFormat(file_format)
                output_res = config.getint(section, "output_res")
                youtube_video.setOutputRes(output_res)
                embed_file_type = config.get(section, "embed_file_type")
                youtube_video.parser.setEmbedType(embed_file_type)
                file_size = config.getint(section, "file_size")
                youtube_video.setFileSize(file_size)
                status = config.getint(section, "status")

                tempitems.append([index, SessionItem(youtube_video, status)])
            except (ConfigParser.NoOptionError, TypeError) as exception:
                print >> sys.stderr, "%s: %s" % (exception.__class__.__name__,
                                                 exception)
                continue
        tempitems.sort(lambda x, y: x[0] - y[0])

        items = []
        for item in tempitems:
            items.append(item[1])

        return items
Exemple #2
0
    def read (self):
        if not os.path.exists (self.session_file_location):
            return []

        tempitems = []
        config = ConfigParser.ConfigParser ()
        config.read (self.session_file_location)
        section_list = config.sections ()
        for section in section_list:
            try:
                index = int (section.strip ("session_video_"))
            except ValueError as exception:
                print >> sys.stderr, "Session \"%s\" has invalid identifier" % section
                continue

            try:
                page_url = config.get (section, "page_url")
                youtube_video = parser_manager.validateURL (page_url)
                if not youtube_video:
                    continue

                title = config.get (section, "title")
                youtube_video.setTitle (title)
                real_url = config.get (section, "real_url")
                youtube_video.setRealUrl (real_url)
                flv_file = config.get (section, "flv_file")
                youtube_video.setFlvFile (flv_file)
                avi_file = config.get (section, "avi_file")
                youtube_video.setOutputFile (avi_file)
                file_format = config.getint (section, "file_format")
                youtube_video.setFileFormat (file_format)
                output_res = config.getint (section, "output_res")
                youtube_video.setOutputRes (output_res)
                embed_file_type = config.get (section, "embed_file_type")
                youtube_video.parser.setEmbedType (embed_file_type)
                file_size = config.getint (section, "file_size")
                youtube_video.setFileSize (file_size)
                status = config.getint (section, "status")                

                tempitems.append ([index, SessionItem (youtube_video, status)])
            except (ConfigParser.NoOptionError, TypeError) as exception:
                print >> sys.stderr, "%s: %s" % (exception.__class__.__name__, exception)
                continue
        tempitems.sort (lambda x, y: x[0]-y[0])

        items = []
        for item in tempitems:
            items.append (item[1])

        return items
Exemple #3
0
    def getVideoInformation(self, account="", password=""):
        if not isinstance(account, str) or not isinstance(password, str):
            raise TypeError("Username and password arguments must be strings")

        page = newurl = ""
        # VERY primitive video portal support
        if self.parser.is_portal:
            # Get initial video page
            if account or password:
                page, newurl = self.parser.getVideoPage(account, password)
            else:
                page, newurl = self.parser.getVideoPage()

            # If no data was passed, assume that the portal is forwarding to a new site
            if not page:
                # Check if the portal forwarded to a site that is supported
                from parsermanager import ParserManager as parser_manager
                parser = parser_manager.validateURL(newurl, False)
                if not parser:
                    raise self.parser.InvalidPortal(
                        "The portal forwarded to a site not supported by this application"
                    )
                # Check if the parser has changed by checking the page urls
                elif self.parser.page_url != parser.page_url:
                    self.parser = parser

                # Get real video page data
                if account or password:
                    page, newurl = self.parser.getVideoPage(account, password)
                else:
                    page, newurl = self.parser.getVideoPage()

        elif account or password:
            page, newurl = self.parser.getVideoPage(account, password)
        else:
            page, newurl = self.parser.getVideoPage()

        title, download_url, headers = self.parser.parseVideoPage(page)
        self.setTitle(title)
        self.real_url = download_url
        if headers.get("Content-Length"):
            self.input_file_size = long(headers.get("Content-Length"))

        return True
Exemple #4
0
    def getVideoInformation (self, account="", password=""):
        if not isinstance (account, str) or not isinstance (password, str):
            raise TypeError ("Username and password arguments must be strings")

        page = newurl = ""
        # VERY primitive video portal support
        if self.parser.is_portal:
            # Get initial video page
            if account or password:
                page, newurl = self.parser.getVideoPage (account, password)
            else:
                page, newurl = self.parser.getVideoPage ()

            # If no data was passed, assume that the portal is forwarding to a new site
            if not page:
                # Check if the portal forwarded to a site that is supported
                from parsermanager import ParserManager as parser_manager
                parser = parser_manager.validateURL (newurl, False)
                if not parser:
                    raise self.parser.InvalidPortal ("The portal forwarded to a site not supported by this application")
                # Check if the parser has changed by checking the page urls
                elif self.parser.page_url != parser.page_url:
                    self.parser = parser

                # Get real video page data
                if account or password:
                    page, newurl = self.parser.getVideoPage (account, password)
                else:
                    page, newurl = self.parser.getVideoPage ()


        elif account or password:
            page, newurl = self.parser.getVideoPage (account, password)
        else:
            page, newurl = self.parser.getVideoPage ()

        title, download_url, headers = self.parser.parseVideoPage (page)
        self.setTitle (title)
        self.real_url = download_url
        if headers.get ("Content-Length"):
            self.input_file_size = long (headers.get ("Content-Length"))

        return True