예제 #1
0
    def _create_url_file(self, url, post, album_size=1):
        """
		Builds the desired sql.File object for the given sql.URL Object.
		Automatically adds the File object to the URL.
		"""
        filename = name_generator.choose_file_name(url=url,
                                                   post=post,
                                                   session=self._session,
                                                   album_size=album_size)
        file = sql.File(path=filename)
        self._session.add(file)
        url.file = file
	def create_url_file(self, sql_url, sql_post, album_size, downloaded=True):
		""" Creates a SQL File object for the given SQL URL & Post. """
		if sql_url.file:
			return sql_url.file
		filename = name_generator.choose_file_name(url=sql_url, post=sql_post, session=self.session, album_size=album_size)
		file = sql.File(
			path=filename
		)
		self.session.add(file)
		sql_url.file = file
		file.downloaded = downloaded
		return file