Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added traceback if the urlretrive fails, folder naming, topic download support and fixed doube download bug #26

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

szero
Copy link
Contributor

@szero szero commented Apr 8, 2016

Here's a link to my fork of this program: https://github.com/Szero/imgur-album-downloader

Added error feedback if the urlretrive fails to download requested in #24

imguralbum.py Outdated
@@ -158,7 +159,7 @@ def save_images(self, foldername=False):
try:
urllib.request.urlretrieve(image_url, path)
except:
print ("Download failed.")
print ("Download failed.\n"+format_exc())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be traceback.print_exc()? (https://docs.python.org/3/library/traceback.html)

szero added 2 commits May 10, 2016 09:22
Creating directories with the same name as the album is a bit problematic because album name may contain characters that are restricted by OS and naming folders with them would cause errors. I overcome this problem by replacing any special characters with `space`
@szero szero changed the title Added traceback if the urlretrive fails Added traceback if the urlretrive fails and folder naming May 10, 2016
@szero szero changed the title Added traceback if the urlretrive fails and folder naming Added traceback if the urlretrive fails along with folder naming May 10, 2016
@szero szero mentioned this pull request May 10, 2016
@szero
Copy link
Contributor Author

szero commented May 10, 2016

Added folder naming requested in #27 in commit [ 71744f1]

All because imgur source changed again!
@szero
Copy link
Contributor Author

szero commented Jul 21, 2016

Added downloading from topics requested in #30 in commit [7c52651]

@szero
Copy link
Contributor Author

szero commented Jul 21, 2016

Fixed double download bug requested in #31 in commit [7c52651]

@szero szero changed the title Added traceback if the urlretrive fails along with folder naming Added traceback if the urlretrive fails, folder naming, topic download support and fixed doube download bug Jul 21, 2016
Now program will save files into folders named after album names. If this is undesired folders can be named by their ID like this:

args = sys.argv
downloader = ImgurAlbumDownloader(args[1])
downloader.save_images(downloader.album_key)
@cyian-1756
Copy link

It errors out with

File "imguralbum.py", line 200, in <module> downloader = ImgurAlbumDownloader(args[1]) File "imguralbum.py", line 83, in __init__ self.album_title = re.search('image\s*:\s*{"id":"%s","title":"(.*?)"' % self.album_key ,html).group(1) AttributeError: 'NoneType' object has no attribute 'group'

When downloading NSFWThisNFSW

Another pesky imgur front-end update!
@szero
Copy link
Contributor Author

szero commented Jul 28, 2016

@cyian-1756 Hey, thanks for the insight. It should be all good now.

@cyian-1756
Copy link

@szero Your version can run into issues if it can't find the album name, you might want to check out falling back to the old version naming (The album ID) in that case.

Traceback (most recent call last): File "/home/user/imgur-album-downloader", line 226, in <module> downloader.save_images(albumFolder) File "/home/user/imgur-album-downloader", line 158, in save_images os.makedirs(albumFolder) File "/usr/lib/python3.5/os.py", line 241, in makedirs mkdir(name, mode) FileNotFoundError: [Errno 2] No such file or directory: ''

@szero
Copy link
Contributor Author

szero commented Jul 31, 2016

Could you include link to the image that caused no album match?

On 31/07/16 04:08, cyian-1756 wrote:

@szero https://github.com/Szero Your version can run into issues if
it can't find the album name, you might want to check out falling back
to the old version naming (The album ID) in that case.

|Traceback (most recent call last):
File "/home/user/imgur-album-downloader", line 226, in
downloader.save_images(albumFolder)
File "/home/user/imgur-album-downloader", line 158, in save_images
os.makedirs(albumFolder)
File "/usr/lib/python3.5/os.py", line 241, in makedirs
mkdir(name, mode)
FileNotFoundError: [Errno 2] No such file or directory: ''|


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#26 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/APBPc7YByO12Cus_KVTrhjkTKRkslQSHks5qbAONgaJpZM4IDNl1.

@cyian-1756
Copy link

@szero It was NSFW This NSFW.

@szero
Copy link
Contributor Author

szero commented Aug 5, 2016

@cyian-1756 Thanks for the input. I adjusted this for your suggestions.

@cyian-1756
Copy link

@szero I've noticed that if 2 albums have the same name this will put all the downloaded pictures from both albums into one folder, wouldn't it be better (at least for archivers) to add the album ID to the folder if a folder with the same name already exists?

@szero
Copy link
Contributor Author

szero commented Jan 24, 2017

@cyian-1756 I added option that names downloaded albums after their ID's. just use it like that: ./imguralbum.py [URL] --use-ids It will name albums after their ID. Making it automated like you suggests it's not good because if album names are the same that usually means they are the same albums on imgur and it would result in downloading same album twice. Cheers.

@szero szero mentioned this pull request May 26, 2017
@szero szero mentioned this pull request Nov 13, 2017
@ghost
Copy link

ghost commented Nov 15, 2017

Hi, you pulled me over from the other thread on imgur album downloader. How does this one fix urls not working?

I tried in terminal "python3 [imgur-album-downloader-master in the right location.py] https://imgur.com/gallery/wfMp9 ~/desktop"

and it told me something similar/the-same-as-the-original-version-of-this-program

"response_code = e.code
AttributeError: 'URLError' object has no attribute 'code' "

    - Better error handling on urlopen method
    - Added property decorators to 4 methods
    - Refactored some code according to pylint
@szero
Copy link
Contributor Author

szero commented Nov 15, 2017

Hello again, @Coaggly. The stack trace indicates that it is some sort of URL error that wasn't handled properly before. I updated the code so it has more verbose output now. It can be caused by outdated certificates on your system, or something trivial like lack of internet connection. If you are using some Linux-based system, try updating the package lists and upgrade your packages. The package you would be looking to upgrade if it would be the case of the issue is ca-certificates on most distros.

@ghost
Copy link

ghost commented Nov 16, 2017

@szero I'm on mac. I tried updating, same thing. I'm not using homebrew if that makes a difference? I'm really new to this stuff so i don't know if i should be

@szero
Copy link
Contributor Author

szero commented Nov 16, 2017

Are you sure you are running my version? You shouldn't get the same error this time. Please upload full error trace and your python3 version if possible.

@ghost
Copy link

ghost commented Nov 16, 2017

I must apologize, but google isn't telling me how to get the error trace.

I don't suppose you know a good basic tutorial for python that includes something about trace errors? The ones i watched didn't mention much about error trace.

"Python 3.6.3"

@szero
Copy link
Contributor Author

szero commented Nov 17, 2017

By error trace I just meant what program prints after you run it, it can't be same error this time. Please download my release from here: https://github.com/Szero/imgur-album-downloader/archive/master.zip and try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants