Skip to content

Commit

Permalink
Implement #107
Browse files Browse the repository at this point in the history
  • Loading branch information
Nandaka committed Mar 8, 2016
1 parent f1fc72f commit 2630354
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 17 deletions.
12 changes: 11 additions & 1 deletion PixivConfig.py
Expand Up @@ -68,6 +68,7 @@ class PixivConfig:
writeUrlInDescription = False
urlBlacklistRegex = ""
urlDumpFilename = "url_list_%Y%m%d"
dbPath = ''

# IrfanView
createDownloadLists = False
Expand Down Expand Up @@ -439,6 +440,13 @@ def loadConfig(self, path=None):
self.urlDumpFilename = "url_list_%Y%m%d"
haveError = True

try:
self.dbPath = config.get('Settings','dbPath')
except ValueError:
print "dbPath = ''"
self.dbPath = ''
haveError = True

## except ConfigParser.NoOptionError:
## print 'Error at loadConfig():',sys.exc_info()
## print 'Failed to read configuration.'
Expand Down Expand Up @@ -517,6 +525,7 @@ def writeConfig(self, error=False, path=None):
config.set('Settings', 'writeUrlInDescription', self.writeUrlInDescription)
config.set('Settings', 'urlBlacklistRegex', self.urlBlacklistRegex)
config.set('Settings', 'urlDumpFilename', self.urlDumpFilename)
config.set('Settings', 'dbPath', self.dbPath)

config.add_section('Authentication')
config.set('Authentication', 'username', self.username)
Expand Down Expand Up @@ -614,7 +623,8 @@ def printConfig(self):
print ' - verifyImage =', self.verifyImage
print ' - writeUrlInDescription =', self.writeUrlInDescription
print ' - urlBlacklistRegex =', self.urlBlacklistRegex
print ' - urlDumpFilename =', self.urlDumpFilename
print ' - urlDumpFilename =', self.urlDumpFilename
print ' - dbPath =', self.dbPath

print ' [Pixiv]'
print ' - numberOfPage =', self.numberOfPage
Expand Down
8 changes: 7 additions & 1 deletion PixivDBManager.py
Expand Up @@ -17,7 +17,13 @@ class PixivDBManager:
"""Pixiv Database Manager"""
__config__ = None

def __init__(self, target = script_path + os.sep + "db.sqlite", config=None):
def __init__(self, target = '', config=None):
if target is None or len(target) == 0:
target = script_path + os.sep + "db.sqlite"
PixivHelper.printAndLog('info',"using default DB Path: " + target)
else:
PixivHelper.printAndLog('info',"using custom DB Path: " + target)

self.conn = sqlite3.connect(target)
if config is not None:
self.__config__ = config
Expand Down
4 changes: 3 additions & 1 deletion PixivUtil2.py
Expand Up @@ -45,7 +45,7 @@

__config__ = PixivConfig.PixivConfig()
configfile = "config.ini"
__dbManager__ = PixivDBManager.PixivDBManager(config = __config__)
__dbManager__ = None
__br__ = None
__blacklistTags = list()
__suppressTags = list()
Expand Down Expand Up @@ -1689,6 +1689,7 @@ def main():
global __br__
global configfile
global ERROR_CODE
global __dbManager__

parser = setup_option_parser()
(options, args) = parser.parse_args()
Expand Down Expand Up @@ -1762,6 +1763,7 @@ def main():
start_irfan_slide = False

try:
__dbManager__ = PixivDBManager.PixivDBManager(target = __config__.dbPath, config = __config__)
__dbManager__.createDatabase()

if __config__.useList:
Expand Down
33 changes: 19 additions & 14 deletions changelog.txt
@@ -1,3 +1,8 @@
20160308-beta1
- Fix unicode decode error when downloading image.
- Implement #107: add option to specify different database.
- Update readme.txt

20160211:
- Fix Issue #98: Fix error message when download fail.
- Add option to filter artist image bookmark by tags.
Expand All @@ -9,7 +14,7 @@
20151112:
- Fix Issue #96: page 100 is not downloaded for new illust page.
- Update test page.
- Implement Feature #95: dump url list to text file.
- Implement Feature #95: dump url list to text file.
Set writeUrlInDescription = True to enable.
Set urlBlacklistRegex to define url to ignore.
Set urlDumpFilename to define the dump filename, use python strftime() format.
Expand Down Expand Up @@ -150,7 +155,7 @@

20130927
- Change some command line syntax:
- Download by Tags (3): wilcard[y/n], start page, end page, tags
- Download by Tags (3): wilcard[y/n], start page, end page, tags
- Download by Title Caption (9): start page, end page, title/captions
- Download by Tags and MemberId (10): MemberId, start page, end page, tags
- Download by Group ID (12): GroupId, limit, process external[y/n]
Expand Down Expand Up @@ -195,7 +200,7 @@
allow user to skip to next image or abort the whole process.

20130327
- Add option to keep signed in, set keepsignedin = 1 in config.ini on
- Add option to keep signed in, set keepsignedin = 1 in config.ini on
[Authentication] section.
- Add login error message parser.

Expand All @@ -208,7 +213,7 @@
tag search.

20130316
- Add option to skip image if worksDate < dateDiff, this will skip to next
- Add option to skip image if worksDate < dateDiff, this will skip to next
member, or stop processing for download from new bookmark.

20130308
Expand All @@ -235,9 +240,9 @@

20121208
- Update no image detection for member
- Fix issue #14: ignore showcase for download by tag
- Fix issue #14: ignore showcase for download by tag
- Fix issue #15: Update query for search by tag
- Add R-18 mode in search by tag
- Add R-18 mode in search by tag

20121124
- Update error detection for image page.
Expand All @@ -254,7 +259,7 @@
- %original_artist% ==> for bookmark mode, put original artist name.

20121102
- Add feature to export image information to text file.
- Add feature to export image information to text file.
- Set writeimageinfo = True to use.

20121028
Expand Down Expand Up @@ -365,7 +370,7 @@
- Update tags list parser to handle text files with BOM.
- Add blacklist and suppress tags list.
- useblacklisttags = True/False
Skip image if containing blacklisted tags.
Skip image if containing blacklisted tags.
The list is taken from blacklist_tags.txt, each tags is separated by new line.
- usesuppresstags = True/False
Remove the suppressed tags from %tags% meta for filename.
Expand Down Expand Up @@ -437,8 +442,8 @@

20111028
- Fix artist name parsing.
- Add download by tag list.
- Separate each tags by space or paste the encoded query string.
- Add download by tag list.
- Separate each tags by space or paste the encoded query string.
- Separate with new line for each query.
- Add Export user bookmarks.
- Add Database cleanup. Go to Manage Database -> Clean Up Database.
Expand All @@ -447,7 +452,7 @@

20111017
- Add download by user bookmark.
- Add createMangaDirectory option. The generated directory is based on the filenameFormat and the filename is
- Add createMangaDirectory option. The generated directory is based on the filenameFormat and the filename is
from the page marker '_p##'+ file extension.

20110922
Expand All @@ -463,8 +468,8 @@
20110911
- Update Login process.
- Add filesize checking when downloading avatar image.
- Change the parser from mechanize.DefaultFactory() to mechanize.RobustFactory().
For downloading still using the default factory because there is a problem (ValueError: invalid literal for int()
- Change the parser from mechanize.DefaultFactory() to mechanize.RobustFactory().
For downloading still using the default factory because there is a problem (ValueError: invalid literal for int()
with base 10: 'some_chars') if using robust factory (20110911b).
- Fix artist token parser when there is no profile image (20110911b).

Expand Down Expand Up @@ -544,7 +549,7 @@
- added feature: when (directly or indirectly) set in config.ini pixivUtil will create lists of your downloaded images in <Downloaded_on_YYYY_MM_DD.txt> (using date when pixivUtil is launched).
- added feature: start IrfanView when exiting pixivUtil (Slideshow will be started before normal IrfanView-Window).
- added feature: typing <-all> in menu will temporarily activate/deactivate pagelimit set in config.ini (it will set commandline-option <-n 0>).

20100908::
- Updated find by tags.
- by Yavos:
Expand Down
2 changes: 2 additions & 0 deletions readme.txt
Expand Up @@ -206,6 +206,7 @@ Q6: httperror_seek_wrapper: HTTP Error 403: request disallowed by robots.txt
downloaded_on_%date%.txt
-n NUMBEROFPAGES, --numberofpages=NUMBEROFPAGES
temporarily overwrites numberOfPage set in config.ini
-c [PATH], --config [PATH] provide different config.ini

=================================================================================
= error codes =
Expand Down Expand Up @@ -384,6 +385,7 @@ urlBlacklistRegex ==> Used to filter out the url in the description using
regular expression.
urlDumpFilename ==> Define the dump filename, use python strftime() format.
Default value is 'url_list_%Y%m%d'
dbPath ==> use different database.

=================================================================================
= list.txt Format =
Expand Down

0 comments on commit 2630354

Please sign in to comment.