Nandaka / PixivUtil2

Download images from Pixiv and more!
http://nandaka.devnull.zone/
BSD 2-Clause "Simplified" License
2.4k stars 254 forks source link

Question: Is it possible to run om Mac OS X? #45

Closed JarnoLeConte closed 10 years ago

JarnoLeConte commented 10 years ago

Building from source means that you can run it on Mac OS X? I tried to replace the default setup.py file with one created by 'py2applet' which will use 'py2app' to make a Mac OS X distribution. But the generated application crashes after startup. Does someone know, how this must be done?

I used the following command to create a setup file:

py2applet --make-setup PixivUtil2.py --iconfile icon-mac.icns 

I made small changes in the setup file to avoid some errors. This is the resulting file:

"""
This is a setup.py script generated by py2applet

Usage:
    python setup.py py2app
"""

from setuptools import setup

APP = ['PixivUtil2.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True,
 'iconfile': '/Users/connect/Desktop/PixivUtil2-master/icon-mac.icns'}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app','BeautifulSoup']
)

Then I try to build a executable by entering:

python setup.py py2app

After starting up the application, some window shows up with the message "PixivUtil2 Error". In the console there are these errors:

05-09-14 14:14:20,755 PixivUtil2[1409]: ]2;PixivDownloader 20140712 PixivDownloader2 version 20140712
05-09-14 14:14:20,756 PixivUtil2[1409]: https://nandaka.wordpress.com/tag/pixiv-downloader/
05-09-14 14:14:20,756 PixivUtil2[1409]: Reading /Users/connect/Desktop/PixivUtil2-master/dist/PixivUtil2.app/Contents/MacOS/config.ini ...
05-09-14 14:14:20,756 PixivUtil2[1409]: Error at loadConfig(): (<type 'exceptions.IOError'>, IOError(2, 'No such file or directory'), <traceback object at 0x10481ff80>)
05-09-14 14:14:20,756 PixivUtil2[1409]: Some configuration have invalid value, replacing with the default value.
05-09-14 14:14:20,757 PixivUtil2[1409]: Writing config file... Backing up old config (error exist!) to config.ini.error-1409919260
05-09-14 14:14:20,757 PixivUtil2[1409]: done.
05-09-14 14:14:20,757 PixivUtil2[1409]: done.
05-09-14 14:14:20,762 PixivUtil2[1409]: Traceback (most recent call last):
05-09-14 14:14:20,762 PixivUtil2[1409]:   File "/Users/connect/Desktop/PixivUtil2-master/dist/PixivUtil2.app/Contents/Resources/__boot__.py", line 373, in <module>
05-09-14 14:14:20,762 PixivUtil2[1409]:     _run()
05-09-14 14:14:20,762 PixivUtil2[1409]:   File "/Users/connect/Desktop/PixivUtil2-master/dist/PixivUtil2.app/Contents/Resources/__boot__.py", line 358, in _run
05-09-14 14:14:20,762 PixivUtil2[1409]:     exec(compile(source, path, 'exec'), globals(), globals())
05-09-14 14:14:20,762 PixivUtil2[1409]:   File "/Users/connect/Desktop/PixivUtil2-master/dist/PixivUtil2.app/Contents/Resources/PixivUtil2.py", line 1828, in <module>
05-09-14 14:14:20,762 PixivUtil2[1409]:     main()
05-09-14 14:14:20,762 PixivUtil2[1409]:   File "/Users/connect/Desktop/PixivUtil2-master/dist/PixivUtil2.app/Contents/Resources/PixivUtil2.py", line 1718, in main
05-09-14 14:14:20,763 PixivUtil2[1409]:     dfilename = PixivHelper.toUnicode(sys.path[0], encoding=sys.stdin.encoding) + os.sep + dfilename
05-09-14 14:14:20,763 PixivUtil2[1409]:   File "PixivHelper.pyc", line 279, in toUnicode
05-09-14 14:14:20,763 PixivUtil2[1409]: TypeError: unicode() argument 2 must be string, not None
05-09-14 14:14:20,781 PixivUtil2[1409]: PixivUtil2 Error
05-09-14 14:14:20,781 PixivUtil2[1409]: 2014-09-05 14:14:20.780 PixivUtil2[1409:707] PixivUtil2 Error
Hamuko commented 10 years ago

I don't really understand why you're trying to turn it into an app.

All you need to do is satisfy the module requirements (mechanize 0.2.5, BeautifulSoup 3.2.0, socksipy-branch 1.02+) and run the script. You can either get them with pip, easy_install or just throw the modules into the same directory as PixivUtil2. Then just run python PixivUtil2.py on the command-line.

I use it on OS X on a daily basis.

JarnoLeConte commented 10 years ago

I thought that some functionality was only available through the UI. But you are right, it works well using the Terminal. But logging in through the Terminal will not work, I had to copy the cookie manually as was written in the FAQ.

Hamuko commented 10 years ago

Logging through command-line works fine for me, although I normally use my username and password in the config file (for scripting purposes). Just remember that even if you can't see your password in the command-line, it's still being entered. I copy-pasted mine, though, as I use a password manager. Also, I think the login names are all lower-case. Mine certainly is, even though it's with a capital first letter on my profile page.

JarnoLeConte commented 10 years ago

Thanks for the additional information, but that is not the problem in my case. I found out that setting the "userrobots" setting to False will solve the problem. I'm not sure what that means and why it give different results. But it make sense because the error before was about Pixiv blocking my request because of robots.txt. I should think that everyone should have that problem because of the predefined user agent within the settings file, don't you think?

Nandaka commented 10 years ago

I don't set the default for userobot = false to make sure user read the readme.txt.

I don't think user agent should have any impact as I'm still using the default one.

kode54 commented 10 years ago

I don't think user agent matters. There are some sites which strictly enforce robots.txt on any client which actually retrieves robots.txt in the first place, and if there is a * rule, it enforces it on all clients that retrieve robots.txt regardless of what their user agent string is.