示例#1
0
	def process_url(self, url, url_index, child):
		self.debug('process_url: %s' % url)
		userid = self.db.get_user_id(child.author)
		if type(child) == Post:
			base_fname = '%s-%d' % (child.id, url_index)
			postid = child.id
			commid = None
		elif type(child) == Comment:
			base_fname = '%s-%s-%d' % (child.post_id, child.id, url_index)
			postid = child.post_id
			commid = child.id

		working_dir = path.join(ImageUtils.get_root(), 'content', child.author)

		# A single URL can contain multiple medias (i.e. albums)
		try:
			(media_type, albumname, medias) = ImageUtils.get_urls(url)
		except Exception, e:
			self.debug('%s: process_url: unable to get URLs for %s: %s' % (child.author, url, str(e)))
			return
示例#2
0
    def process_url(self, url, url_index, child):
        self.debug('process_url: %s' % url)
        userid = self.db.get_user_id(child.author)
        if type(child) == Post:
            base_fname = '%s-%d' % (child.id, url_index)
            postid = child.id
            commid = None
        elif type(child) == Comment:
            base_fname = '%s-%s-%d' % (child.post_id, child.id, url_index)
            postid = child.post_id
            commid = child.id

        working_dir = path.join(ImageUtils.get_root(), 'content', child.author)

        # A single URL can contain multiple medias (i.e. albums)
        try:
            (media_type, albumname, medias) = ImageUtils.get_urls(url)
        except Exception, e:
            self.debug('%s: process_url: unable to get URLs for %s: %s' %
                       (child.author, url, str(e)))
            return
示例#3
0
    def process_url(self, url, url_index, child):
        self.debug('%s: process_url: %s' % (child.author, url))

        # Ignore duplicate albums
        if self.db.album_exists(url):
            self.debug('''%s: process_url: album %s already exists in database.
Permalink: %s
   Object: %s''' % (child.author, url, child.permalink(), str(child)))
            return

        userid = self.db.get_user_id(child.author)
        if type(child) == Post:
            base_fname = '%s-%d' % (child.id, url_index)
            postid = child.id
            commid = None
        elif type(child) == Comment:
            base_fname = '%s-%s-%d' % (child.post_id, child.id, url_index)
            postid = child.post_id
            commid = child.id

        working_dir = path.join(ImageUtils.get_root(), 'content', child.author)

        # A single URL can contain multiple medias (i.e. albums)
        try:
            (media_type, albumname, medias) = ImageUtils.get_urls(url)
        except Exception, e:
            self.debug('%s: process_url: unable to get URLs for %s: %s' %
                       (child.author, url, str(e)))
            if 'domain not supported' in str(e):
                # Save domain-not-supported URLs to new file
                user_dir = path.join(ImageUtils.get_root(), 'content',
                                     child.author)
                f = open(path.join(user_dir, 'unsupported.txt'), 'a')
                f.write(url)
                f.write('\n')
                f.flush()
                f.close()
            return
示例#4
0
	def process_url(self, url, url_index, child):
		self.debug('%s: process_url: %s' % (child.author, url))

		# Ignore duplicate albums
		if self.db.album_exists(url):
			self.debug('''%s: process_url: album %s already exists in database.
Permalink: %s
   Object: %s''' % (child.author, url, child.permalink(), str(child)))
			return

		userid = self.db.get_user_id(child.author)
		if type(child) == Post:
			base_fname = '%s-%d' % (child.id, url_index)
			postid = child.id
			commid = None
		elif type(child) == Comment:
			base_fname = '%s-%s-%d' % (child.post_id, child.id, url_index)
			postid = child.post_id
			commid = child.id

		working_dir = path.join(ImageUtils.get_root(), 'content', child.author)

		# A single URL can contain multiple medias (i.e. albums)
		try:
			(media_type, albumname, medias) = ImageUtils.get_urls(url)
		except Exception, e:
			self.debug('%s: process_url: unable to get URLs for %s: %s' % (child.author, url, str(e)))
			if 'domain not supported' in str(e):
				# Save domain-not-supported URLs to new file
				user_dir = path.join(ImageUtils.get_root(), 'content', child.author)
				f = open(path.join(user_dir, 'unsupported.txt'), 'a')
				f.write(url)
				f.write('\n')
				f.flush()
				f.close()
			return
示例#5
0
文件: test.py 项目: mkdfgj/gwstar
	def main(self):
		
		url='http://i.reddituploads.com/565bfd920d114339930a3e2407a5d967'
		ImageUtils.get_urls(url)