Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def ouroboros(site, uri):
- # e621 and twentypercentcooler use the same software
- # TODO: load tag file; compare tags, generate title
- #load a list of unimportant tags from a file. possible regex?
- title = ''
- def get_id(link):
- exp = '(.*)show/(?P<id>[0-9]*)/?'
- return re.search(exp, link).group('id')
- post_id = get_id(uri)
- json_data = web.get('https://{0}.net/post/show.json?id={1}'.format(site, post_id))
- postdata = json.loads(json_data, encoding='utf-8')
- tags = postdata['tags']
- ratings = { 's' : 'Safe', 'q' : 'Questionable', 'e' : 'Explicit' }
- if postdata['rating'] in ratings:
- rating = ratings[postdata['rating']]
- else:
- rating = 'Unknown'
- #compare tags to a list of uniportant tags and drop some/most
- tag_file = os.path.expanduser('~/.phenny/boru.py')
- try:
- boru = imp.load_source('boru',tag_file)
- except Exception as e:
- print("Error loading ignore tags: {0} (in head.py)".format(e))
- else:
- filteredtags = tags
- listtags = filteredtags.split()
- filtered = filter(not boru.ignore_tags, listtags)
- filteredlist = str(filtered)
- title = str(filteredlist)
- title = '{0} {1}'.format(rating.capitalize(),title)
- return title
Advertisement
Add Comment
Please, Sign In to add comment