RunawayDanish

Local Alien Degenerate opens blog

Time Elapses. The Past Recedes. Do you do the Dinosaur?

Furry artist from the internet, ancient and seasoned at the eon-spanning age of 32. I've been around on Furaffinity.net forever, watch me there too, maybe consider donating dosh to me over on kofi or SubscribeStar, I am unemployable.




All characters are over 18, by the by, and you should be too to visit this page.




PS: A random SFW account, no relation to me, of course.


caffeinatedOtter
@caffeinatedOtter

Incidentally, if you're on a platform where you can reasonably install cohost.py and you can responsibly vet an internet rando's python3 script before running it on your machine, you can use this to dump the text of all posts from a specific Cohost page of yours to individual files in the current working directory, named in the pattern postID_whenposted.md

I have made Choices in order to preserve some out-of-band information: post headline, CWs, and tags. I make no attempt to retrieve anything except text; archiving posted images is outside my use case.

#!/usr/bin/python3

from pathlib import Path
from cohost.models.user import User
from cohost.models.post import Post
from sys import exit


cookie = '' # copy-paste from web browser devtools as per https://github.com/valknight/Cohost.py#retrieving-your-cookie 
projectName = 'caffeinatedOtter' # or whatever your @pagename is

try:
	user = User.loginWithCookie(cookie)
	project = user.getProject(projectName)
except:
	exit('Cohost login failed!')

here = Path.cwd()
page = 0
while True:
	postlist = project.getPosts(page)
	if len(postlist) > 0:
		page = page + 1
		for post in postlist:
			md = post.plainTextBody
			if len(post.contentWarnings) > 0:
				cwList = '\n'.join(post.contentWarnings)
				md = f"<!-- CWs:\n{cwList}\n-->\n{md}"
			if len(post.tags) > 0:
				tagList = '\n'.join(post.tags)
				md = f"<!-- tags:\n{tagList}\n-->\n{md}"
			if len(post.headline) > 0:
				md = f"# {post.headline} <!-- Cohost headline -->\n\n{md}"
			if len(md) > 0:
				filename = here / f"{post.postId}_{post.publishedAt}.md"
				filename.write_text(md)
	else:
		print('Done.')
		exit(0)

RunawayDanish
@RunawayDanish

I'm not technically literate enough to vet code and have a busy day ahead of me, but here's one of the writing cohort I've gotten to be familiar with producing an Archival tool.

There is a text-only limitation, as the author notes. Perfect for short stories.


You must log in to comment.