ArmindoFlores / ao3_api

An unofficial archiveofourown.org (AO3) API for python
MIT License
166 stars 64 forks source link

Basic Collection Interactions #70

Closed LordGiacomoS closed 2 years ago

LordGiacomoS commented 2 years ago

Adds:

Required things to get this working:

import AO3 session = AO3.Session("Username/email", "Password") url = "http://archiveofourown.org/works/6037795"

workid = AO3.utils.workid_from_url(url) work = AO3.Work(workid, session)

user_collections = ["Collection1ID","Collection2ID"] work.collect(user_collections)

Additional testing to be done, but I thought I'd share what I have so far since it seems to be working... Mostly. Better functionality for what's counted as an error needs to be added, as that has been a major issue and is currently disabled because of that.

Also, I was learning python as I was working on this, so please don't expect the code to be anywhere near competently written.

ArmindoFlores commented 2 years ago

I have tested it and work.collections seems to be working great! Calling work.collect(...) works but always raises an error;

LordGiacomoS commented 2 years ago

That's why I said it only mostly works... I plan to try and figure out how to fix that in the next few days, but thought that I might as well share what I had since it technically works and only thinks it doesn't. I likely just need to do some testing to see which HTTPS codes would represent actual issues (as they're apparently different than work.bookmark).

LordGiacomoS commented 2 years ago

This should fix the issues with HTTP code 200 being seen as problematic, while maintaining functionality of other errors being raised.

LordGiacomoS commented 2 years ago

Alright, I just found a major issue that I'm going to try and figure out a fix for: Currently, the API can't tell if the collection it tries to add a work to is valid, outputting HTTP code 200 either way.

LordGiacomoS commented 2 years ago

Okay, this should finally all be working properly, but this branch still does not have the ability to interact and manage items already in collections (i.e. approving works to be added, removing works from collections, listing the works in a collection). Addressing the management of existing collections will likely be done in a separate pull request though, as it is only tangentially related.

LordGiacomoS commented 2 years ago

In case it hasn't been clear, I have no clue what I'm doing, and apparently do not understand github very well, so a bunch of stuff that I thought was on separate branch was accidentally been committed to this branch, though it has been reverted as far as I can tell.