예제 #1
0
    def play(self, arg=None, menuw=None):
        """ Play this Podcast"""

        # play the item.
        isYT = self.vp_url.find('youtube.com')  #YouTube podcast
        isMC = self.vp_url.find('metacafe.com')  #Metacafe podcast

        if isYT != -1:
            self.download_url = self.youtube(self.vp_url)

        elif isMC != -1:
            self.download_url = self.metacafe(self.vp_url)

        else:
            self.download_url = self.vp_url

        if not os.path.exists(self.filename):
            background = BGDownload(self.download_url, self.filename)
            background.start()
            popup = PopupBox(text=_('Buffering podcast...'))
            popup.show()
            time.sleep(20)  # 20s. buffering time
            popup.destroy()

        # call the play funuction of VideoItem
        VideoItem.play(self, menuw=menuw, arg=arg)
예제 #2
0
파일: rtve.py 프로젝트: golaizola/freevo1
 def download_play(self, arg=None, menuw=None):
     pop = PopupBox("Descargando programa")
     pop.show()
     video = VideoItem(_fetch_image(arg["flv"]), self)
     pop.destroy()
     video.image = _fetch_image(arg["image"])
     video.menuw = menuw
     video.play()
예제 #3
0
 def download_play(self, arg=None, menuw=None):
     pop = PopupBox("Descargando programa")
     pop.show()
     video = VideoItem(_fetch_image(arg['flv']), self)
     pop.destroy()
     video.image = _fetch_image(arg['image'])
     video.menuw = menuw
     video.play()
예제 #4
0
파일: cml.py 프로젝트: glyph-se/dotfiles
class Trailer(VideoItem):
    def __init__(self, trailer, parent):
        VideoItem.__init__(self, trailer['url'], parent)
        self.name = "%(type)s - %(speed)s" % trailer
        self.trailer = trailer
        self.type = 'video'

    def play(self, arg=None, menuw=None, alternateplayer=False):
        """
        Check url before playing
        """
        # Check to see if there's some intermediate file...
        try:
            trailerdata = urllib2.urlopen(self.trailer['url']).read(1024)
        except HTTPError, e:
            AlertBox("%s %s: %s" % (_("Could not retrieve URL"), self.trailer['url'], e)).show()
            return

        if trailerdata.find('<?quicktime type="application/x-quicktime-media-link"?>') > -1:
            self.set_url(trailerdata.split('src="')[1].split('"')[0])
        elif trailerdata.lower().find('<asx') == 0:
            res = asx_re.search(trailerdata)
            if res:
                self.set_url(res.group(1))
        elif trailerdata.lower().find('rtsp:') == 0:
            self.set_url(trailerdata)
        
        VideoItem.play(self, arg, menuw, alternateplayer)
예제 #5
0
class VPVideoItem(VideoItem):
    """
    Video podcast video item
    """
    def __init__(self, filename, parent, item_url, results):
        """ Initialise the VPVideoItem class """
        logger.log(
            9,
            'VPVideoItem.__init__(filename=%r, parent=%r, item_url=%r, results=%r)',
            filename, parent, item_url, results)

        VideoItem.__init__(self, filename, parent)
        self.item_url = item_url
        self.results = results

    def play(self, arg=None, menuw=None):
        """
        Play this Podcast
        """
        download_failed = False
        self.download_url = self.item_url
        if not os.path.exists(
                self.filename) or os.path.getsize(self.filename) < 1024:
            try:
                background = BGDownload(self.download_url, self.filename,
                                        self.results)
                background.start()
                popup = PopupBox(text=_('Fetching "%s"...' % self.name))
                popup.show()
                try:
                    size = 0
                    for i in range(int(config.VPODCAST_BUFFERING_TIME)):
                        if os.path.exists(self.filename):
                            size = os.stat(self.filename)[stat.ST_SIZE]
                            if size > config.VPODCAST_BUFFERING_SIZE:
                                break
                        time.sleep(1.0)
                    else:
                        if size < config.VPODCAST_BUFFERING_SIZE:
                            download_failed = True
                finally:
                    popup.destroy()
                if download_failed:
                    AlertBox(text=_('Fetching "%s" failed\nNo data') %
                             self.filename).show()
                    return
            except youtube.DownloadError, why:
                AlertBox(text=_('Fetching "%(filename)s" failed:\n%(why)s') %
                         ({
                             'filename': self.filename,
                             'why': why
                         })).show()
                return

        # call the play funuction of VideoItem
        VideoItem.play(self, menuw=menuw, arg=arg)