first commit for cute snep u//w//u

yiff
elburg 1 year ago
commit 8ed5644f81

@ -0,0 +1,81 @@
import logging
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
allowed_exts=[
"tif","tiff", # TIFF
"jpeg","jpg","pjpeg","pjpg","jpe", # JPEG
"webp", # Webp
# "wav","wave", # RIFF Wave
"png","apng" # PNG (since 1.2)
]
def backupMetadata(file):
from PIL import Image, ExifTags
logging.debug(f"loading file {file}")
img = Image.open(file)
logging.debug("file loaded. getting exif")
img_exif = img.getexif()
full=[]
if img_exif is None:
logging.warning("Could not load EXIF Data... Either something happened with Pillow, the file disappeared, or you don't have access to the file. Try running verbose!")
break
else:
logging.debug("loaded tags")
for key, val in img_exif.items():
logging.debug(f"for key:'{key}', val:'{val}' in img_exif.items()")
if key in ExifTags.TAGS:
logging.debug(f"{key} is known exif tag! ({ExifTags.TAGS[key]})")
full.append({
'tagName': str(key),
'realName': str(ExifTags.TAGS[key]),
'value': str(val)
})
else:
logging.warning(f"{key} is an unknown exif tag!")
full.append({
'tagName': str(key),
'realName': None,
'value': str(val)
})
logging.info("writing backup data")
import json
#import tempfile
#temp = tempfile.TemporaryFile(mode='w+')
#json.dump(full,temp,sort_keys=True)
with open(f"{file}.exif_backup.json.xz",'w+b') as bfile
logging.debug(f"writing to {bfile}")
import lzma
bfile.write(lzma.compress(
bytes(json.dumps(full,sort_keys=True)),
format=FORMAT_XZ,
check=CHECK_SHA256,
preset=9
))
logging.debug("wrote backup data")
logging.info("backup done!")
def writeTags(file,tags):
from PIL import Image
image=Image.open(file)
exif = image.getexif()
if artist in tags:
if type(tag.artist) == str:
exif[0x013b] = tags.artist
elif tags.category == "deviantart":
exif[0x013b] = tags.artist.username
if title in tags:
exif[0x0010e] = tags.title
if description in tags:
exif[0x9286] = tags.description

@ -0,0 +1,7 @@
def getPub(input):
if fa_category in input or input.category == 'furaffinity':
return 'Furaffinity'
elif input.category == 'deviantart':
return 'DeviantArt'
else:
return 'Unknown'

@ -0,0 +1,22 @@
# module imports
import sys
import json
import logging
# init logging
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
# variable init
infojson={}
source=sys.argv[1]
logging.info(f"loading info.json for {source}...")
with open(f"{source}.json") as file:
infojson=json.load(file)
# TODO: insert method to check url or dict
logging.debug("determining file type...")
import exif
if infojson.extension in exif.allowed_exts:
logging.debug(f"exif module supports {infojson.extesnion} files. using it... ")

File diff suppressed because it is too large Load Diff

@ -0,0 +1,60 @@
{
"artist": "Englishweasel",
"artist_url": "englishweasel",
"category": "furaffinity",
"comments": 1,
"date": "2022-06-14 21:32:55",
"description": "</td>\n </tr>\n <tr>\n <td valign=\"top\" align=\"left\" width=\"70%\" class=\"alt1\" style=\"padding:8px\">\n Violet has a very huge appetite, so she tries her best to direct it towards the people she feels deserve it. Given her job she often finds the people who she feels are the lowest common denominator of civilization and the government is not above using her talents for making people disappear. All the same, she isnt one to let people out once she has them, and one of the few things that bring her a semblance of joy is knowing she took someone horrid and put them to better use as wolf fat.<br />\r\n<br />\r\nViolet is one of my many many characters<br />\r\nArtwork done by the real O.G. <a href=\"/user/kingcreep105\" class=\"iconusername\"><img src=\"//a.furaffinity.net/20230122/kingcreep105.gif\" align=\"middle\" title=\"_KingCreep105\" alt=\"_KingCreep105\" />&nbsp;_KingCreep105</a> who did a great job with those curves\n </td>\n </tr>",
"extension": "jpg",
"fa_category": "Artwork (Digital)",
"favorites": 279,
"filename": "1655242375.englishweasel_f0800c96-0907-490c-a6a7-0191da61d061_jpeg",
"gender": "Female",
"height": 721,
"id": 47657025,
"rating": "Adult",
"species": "Wolf",
"subcategory": "favorite",
"tags": [
"Violet",
"Siskel",
"Giant",
"Wolf",
"Woman",
"Pred",
"Mass",
"Vore",
"Unwilling",
"Prey",
"Digestion",
"Weight",
"Gain",
"Big",
"Belly",
"Fat",
"Butt",
"Fluffy",
"Tail",
"Dont",
"feel",
"bad",
"for",
"them",
"they",
"deserved",
"it",
"trust",
"me",
"no",
"they",
"wont",
"be",
"okay"
],
"theme": "Vore",
"title": "Better off wolf fat",
"url": "https://d.furaffinity.net/art/englishweasel/1655242375/1655242375.englishweasel_f0800c96-0907-490c-a6a7-0191da61d061_jpeg.jpg",
"user": "shysho",
"views": 1961,
"width": 1280
}

123
xmp.py

@ -0,0 +1,123 @@
"XMP Manipulator for gallery-dl"
import logging
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
allowed_exts=[
"html", "htm", "xhtml", "xht", # HTML
"tif", "tiff", # TIFF
"jpeg", "jpg", "pjpeg", "pjpg", "jpe", # JPEG
"jp2", "jpf", "jpx", "jpm", "mj2", # JPEG 2000
"png", "apng", # PNG
"gif", # GIF
"mp3", # MPEG-1 / MPEG-2 Layer III
"mp4", "m4a", "m4p", "m4b", "m4r", "m4v", # MPEG-4
"mov", "qt", # Apple QuickTime .mov
"pdf", # PDF
"webp" # WebP
]
# def backupMetadata(file: str, outputFileExt: str = "xmp_backup.json.xz") -> bool:
# """Exports XMP metadata inside of a file.
# Parameters
# ----------
# file : str
# Location of the file relative to the working directory.
# outputFileExt : str, optional
# The suffix used for the backup file. By default, the output file will be formatted as such:
# <source filename>.xmp_backup.json.xz
# Returns
# -------
# bool
# True, if operation was successful.
# False, if operation failed.
# """
# from libxmp.utils import file_to_dict
# import json
# with open(f"{file}.xmp_backup.json.xz",'w+b') as bfile
# logging.debug(f"writing to {bfile}")
# import lzma
# bfile.write(lzma.compress(
# bytes(json.dumps(file_to_dict(file),sort_keys=True)),
# format=FORMAT_XZ,
# check=CHECK_SHA256,
# preset=9
# ))
# logging.debug("wrote backup data")
# logging.info("backup done!")
def backupMetadata(file):
import pyexiv2
data = pyexiv2.ImageMetadata(file)
data.read()
full = []
for key in data.xmp_keys:
full.append([
key,
data[key].raw_value
])
with open(f"{file}.xmp_backup.json.xz",'w+b') as bfile
import lzma, json
bfile.write(lzma.compress(
bytes(json.dumps(full)),
format=FORMAT_XZ,
check=CHECK_SHA256,
preset=9
))
# def writeTags(file: str, tags: dict) -> bool:
# """Writes XMP tags to file taking the info.json file as a dict.
# """
# from libxmp import XMPFiles, consts
# xmpfile = XMPFiles(file_path=file,)
# if artist in tags:
# if type(tags.artist) == str:
# xmp.set_property(consts.XMP_NS_DC, u'creator', tags.artist.decode('unicode-escape'))
def writeTags(file, tags):
import pyexiv2
xmptags = pyexiv2.ImageMetadata(file)
xmptags.read()
if artist in tags:
if type(tag.artist) == str:
xmptags['Xmp.dc.creator'] = tags.artist
elif tags.category == "deviantart":
xmptags['Xmp.dc.creator'] = tags.artist.username
if title in tags:
xmptags['Xmp.dc.title'] = tags.title
if description in tags:
xmptags['Xmp.dc.description'] = tags.description
if date in tags:
xmptags['Xmp.dc.date'] = tags.date
from getpub import getPub
xmptags['Xmp.dc.publisher'] = getPub(tags)
del getPub
keywords=[]
if tags in tags: for item in tags.tags: if item not in keywords: keywords.append(item)
if theme in tags and tags.theme not in keywords:
keywords.append(tags.theme)
if rating in tags and tags.rating not in keywords:
keywords.append(tags.rating)
if species in tags and tags.species not in keywords:
keywords.append(tags.species)
if gender in tags and tags.gender not in keywords:
keywords
Loading…
Cancel
Save