Exemplo n.º 1
0
    def _getFirstImageFromFormattedText(self, dir, id):
        """Find the first image, if any, and set the image filename and url accordingly
        
        Argument
        dir -- the directory where the image will be stored
        id -- a readable id of the item

        """
        if(self._formattedtext is not None):
            imagesrc = self._formattedtext.getFirstImage()
            
            if(imagesrc is not None):
                #TBD This is not good
                imagesrc = imagesrc.split('?')[0]
                self._imgsrcurl = imagesrc
                filename = textToFilename(self.uid) + os.path.split(imagesrc)[1]
                self._imagename = os.path.join(dir, filename)
        else:
            self._imgsrcurl = ''
            self._imagename = ''
            print('Could not get formatted text from ' + id)
Exemplo n.º 2
0
            self._rawtext = getCDataNodeValue(rssxml, el_rsscontent)
            self._setUid()
            self._setId()
            self._imagename = ''

        self._formattext()

        if (rssxml is not None):
            if (self._formattedtext is not None):
                imagesrc = self._formattedtext.getFirstImage()

                if (imagesrc is not None):
                    #TBD This is not good
                    imagesrc = imagesrc.split('?')[0]
                    self._imgsrcurl = imagesrc
                    filename = textToFilename(
                        self.uid) + os.path.split(imagesrc)[1]
                    self._imagename = os.path.join(dir, filename)
            else:
                print('Could not get formatted text from ' + title)


#    def loadData(self):
#        """If necessary, download and load the image associated with this WordPressItem."""
#        if((self._imagename != '') and (self.image is None)):
#            try:
#                funcSaveCover.saveGenericImage(self._url, self._imagename)
#                self._loadimage(self._dims, self._smalldims)
#            except IOError:
#                print('Could not get image ' + self._url)

    def _setUid(self):
Exemplo n.º 3
0
            self._rawtext = getCDataNodeValue(rssxml, el_rsscontent)
            self._setUid()
            self._setId()
            self._imagename = ''
            
        self._formattext()
        
        if(rssxml is not None):
            if(self._formattedtext is not None):
                imagesrc = self._formattedtext.getFirstImage()
                
                if(imagesrc is not None):
                    #TBD This is not good
                    imagesrc = imagesrc.split('?')[0]
                    self._imgsrcurl = imagesrc
                    filename = textToFilename(self.uid) + os.path.split(imagesrc)[1]
                    self._imagename = os.path.join(dir, filename)
            else:
                print('Could not get formatted text from ' + title)
                    
#    def loadData(self):
#        """If necessary, download and load the image associated with this WordPressItem."""
#        if((self._imagename != '') and (self.image is None)):
#            try:
#                funcSaveCover.saveGenericImage(self._url, self._imagename)
#                self._loadimage(self._dims, self._smalldims)
#            except IOError:
#                print('Could not get image ' + self._url)

    def _setUid(self):
        """Get the unique identifier for this blog post.