It is currently 19 Apr 2024, 06:04
   
Text Size

Python Code for downloading images from Gatherer

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Python Code for downloading images from Gatherer

Postby Rajarshi » 26 Aug 2016, 15:12

Hi, everyone.
I have written this small python code to directly download images from Gatherer. With this script, Forge will not need any image URLs. The script automatically assigns the ".full.jpg" to the images. If the images are in PNG format, this script also invokes Mogrify from Bash to change them in Bash into JPG. However, you will need the Imagemagik package to do this. (the command is
Code: Select all
sudo apt-get install imagemagik
in Linux)
The script automatically obtains the names of the cards by searching the Gatherer database, so there is no need to use any special database to store card names for images. What you need to do is enter the full string of the set name, the format (jpg/png) in which the images are stored, the number of pages in Gatherer's listing of cards in that set (simply enter the set in Gatherer and leave all other fields blank, and check how many pages there are; leave this blank if you are not sure) and Bang! The script will start downloading images one after the other.
This is only a preliminary version, and can only run on Linux and must be invoked via command line. I am trying to improve this by implementing the following changes:
[*] Using Tkinter to implement a GUI, with a dropdown box containing set names
[*] Automatically determining the image format and number of pages from set name
[*] Replacing the need for Mogrify with default Python libraries
[*] Making this platform independent
NOTE: this code assumes pics are stored in:
Code: Select all
~/.cache/forge/pics/cards/
There seems to be some problem in including the code here, because it uses the urllib2 library, and there are some off-site URLs. The moderator-bot says: "Your post looks too spamy for a new user, please remove off-site URLs."
Is there any way I can send this code without being sent of with a scolding?
Rajarshi
 
Posts: 2
Joined: 23 Aug 2016, 12:14
Has thanked: 0 time
Been thanked: 0 time

Re: Python Code for downloading images from Gatherer

Postby vinnie » 18 Oct 2016, 22:25

I wish I could get the code, i am the author of another script but your program works differently and could be useful.

You can attach the source like I did, renaming it into .txt file.
User avatar
vinnie
 
Posts: 111
Joined: 21 Dec 2015, 14:03
Has thanked: 23 times
Been thanked: 6 times

Re: Python Code for downloading images from Gatherer

Postby xbon » 26 Oct 2016, 16:58

though, there's already gatherer extractor ( http://www.mtgsalvation.com/forums/magi ... abase-pics ) but yes, you could attach it as a .txt file I believe unless there's new user restrictions on those as well.
xbon
 
Posts: 123
Joined: 04 Jun 2013, 22:52
Has thanked: 18 times
Been thanked: 2 times

Re: Python Code for downloading images from Gatherer

Postby vinnie » 26 Oct 2016, 22:23

OK, and in fact I used gatherer extracotr, but it's only for windows, and I also would be interested to see the code to understand what solution he had found.
However gatherer extractor uses different names conventions for sets (I had to watch all the matches by hand, maybe I post them later), and after downloading all images of the sets, forge tells me still lacking 681 pictures, that I do not know how to become aware of what they are.
User avatar
vinnie
 
Posts: 111
Joined: 21 Dec 2015, 14:03
Has thanked: 23 times
Been thanked: 6 times


Return to Forge

Who is online

Users browsing this forum: No registered users and 93 guests


Who is online

In total there are 93 users online :: 0 registered, 0 hidden and 93 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 93 guests

Login Form