credit.py

3 min read

Deviation Actions

decoherence's avatar
By
Published:
2.1K Views
I do my best to credit all the authors of all the vectors. It takes quite a bit of time to make all of those links you see at the bottom of each comic. Lots of copying and pasting and selecting certain bits with the mouse and digging around here and there and blah blah blah. Since I'm doing this for fun, I'd like to minimize the not-fun part as much as possible. I've been meaning to write a script to help with this for a long time.

When I download a vector from DA, I don't rename it. So I have files with names like "obey_pinkie_by_alexiy777-d4w1e8z.png". The file name handily contains enough information to be able to link back to the work on DA if you know the format. I also name all of my photoshop layers after the image that they contain. That means I can create a 'credit line' by analyzing the name of the layers.

I should be able to write a script that takes the 'ID' part (d4w1e8z) and spits out a full credit line, ripe for me to paste in to DA. And indeed I can -- here it is.

import glob
import sys
from os.path import split

def find_file(art_id, mypath='/Users/decoherence/Pictures/'):
    print('searching for {0}**/*{1}*'.format(mypath,art_id))
    result=glob.glob('{0}**/*{1}*'.format(mypath,art_id), recursive=True)
    filename=split(result[0])[-1]
    return(filename)

def get_info(file):
    artist, art_id = file.split('_by_')[-1].split('.')[0].split('-')
    return(artist, art_id)
       
def generate_credit_string(artist,art_id):
    credit_string = ':icon{0}: http://{0}.deviantart.com/gallery/#/{1}'.format(artist, art_id)
    return(credit_string)

if __name__ == '__main__':
    horsefile = find_file(sys.argv[1])
    artist, art_id=get_info(horsefile)
    credit = generate_credit_string(artist, art_id)
    print(credit)

For example:

$ python .\creditor.py d4w1e8z
searching for /Users/decoherence/Pictures/**/*d4w1e8z*
:iconalexiy777: fav.me/d4w1e8z

I just take that last line and paste it in to DA et viola, alexiy777 has a credit!

errr... I realize that shows up as a link, above. I guess that's proof that it works. The real output looks more like this
: iconalexiy777 : ht tp://alexiy777.deviantart.com/gallery/#/d4w1e8z
that's purposefully broken so that it prints. If anyone knows how to keep that from being interpreted by DA's magic parser, let me know!

To further automate it I think I would have to do some kind of Photoshop integration or start organizing pictures differently (like copying or linking them to the project folder for each comic, for instance) but this script cuts down about 80% of the manual labour so it will do for now.
© 2016 - 2024 decoherence
Comments0
Join the community to add your comment. Already a deviant? Log In