{ "info": { "author": "Alex Chan", "author_email": "alex@alexwlchan.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Other Audience", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "ao3.py\n======\n\nThis Python package provides a scripted interface to some of the data on\n`AO3 `_ (the Archive of Our Own).\n\nIt is **not** an official API.\n\nMotivation\n**********\n\nI want to be able to write Python scripts that use data from AO3.\n\nAn official API for AO3 data has been `on the roadmap `_\nfor a couple of years. Until that appears, I've cobbled together my own\npage-scraping code that does the job. It's a bit messy and fragile, but it\nseems to work most of the time.\n\nIf/when we get the proper API, I'd drop this in a heartbeat and do it\nproperly.\n\nInstallation\n************\n\nInstall using pip:\n\n.. code-block:: console\n\n $ pip install ao3\n\nI'm trying to support Python 2.7, Python 3.3+ and PyPy.\n\nUsage\n*****\n\nCreate an API instance:\n\n.. code-block:: pycon\n\n >>> from ao3 import AO3\n >>> api = AO3()\n\nLooking up information about a work\n-----------------------------------\n\nGetting a work:\n\n.. code-block:: pycon\n\n >>> work = api.work(id='258626')\n\nThe ``id`` is the numeric portion of the URL. For example, the work ID of\n``https://archiveofourown.org/works/258626`` is ``258626``.\n\nGet a URL:\n\n.. code-block:: pycon\n\n >>> work.url\n 'https://archiveofourown.org/works/258626'\n\nYou can then look up a number of attributes, similar to the Stats panel at the\ntop of a page. Here's the full set you can look up:\n\n.. code-block:: pycon\n\n >>> work.title\n 'The Morning After'\n\n >>> work.author\n 'ambyr'\n\n >>> work.summary\n \"

Delicious just can't understand why it's the shy, quiet ones who get all the girls.

\"\n\n >>> work.rating\n ['Teen And Up Audiences']\n\n >>> work.warnings\n []\n\n(An empty list is synonymous with \"No Archive Warnings\", so that it's a falsey\nvalue.)\n\n.. code-block:: pycon\n\n >>> work.category\n ['F/M']\n\n >>> work.fandoms\n ['Anthropomorfic - Fandom']\n\n >>> work.relationship\n ['Pinboard/Fandom']\n\n >>> work.characters\n ['Pinboard', 'Delicious - Character', 'Diigo - Character']\n\n >>> work.additional_tags\n ['crackfic', 'Meta', 'so very not my usual thing']\n\n >>> work.language\n 'English'\n\n >>> work.published\n datetime.date(2011, 9, 29)\n\n >>> work.words\n 605\n\n >>> work.comments\n 122\n\n >>> work.kudos\n 1238\n\n >>> for name in work.kudos_left_by:\n ... print(name)\n ...\n winterbelles\n AnonEhouse\n SailAweigh\n # and so on\n\n >>> work.bookmarks\n 99\n\n >>> work.hits\n 43037\n\nThere's also a method for dumping all the information about a work into JSON,\nfor easy export/passing into other places:\n\n.. code-block:: pycon\n\n >>> work.json()\n '{\"rating\": [\"Teen And Up Audiences\"], \"fandoms\": [\"Anthropomorfic - Fandom\"], \"characters\": [\"Pinboard\", \"Delicious - Character\", \"Diigo - Character\"], \"language\": \"English\", \"additional_tags\": [\"crackfic\", \"Meta\", \"so very not my usual thing\"], \"warnings\": [], \"id\": \"258626\", \"stats\": {\"hits\": 43037, \"words\": 605, \"bookmarks\": 99, \"comments\": 122, \"published\": \"2011-09-29\", \"kudos\": 1238}, \"author\": \"ambyr\", \"category\": [\"F/M\"], \"title\": \"The Morning After\", \"relationship\": [\"Pinboard/Fandom\"], \"summary\": \"

Delicious just can\\'t understand why it\\'s the shy, quiet ones who get all the girls.

\"}'\n\nLooking up your account\n-----------------------\n\nIf you have an account on AO3, you can log in to access pages that aren't\navailable to the public:\n\n.. code-block:: pycon\n\n >>> api.login('username', 'password')\n\nCurrently there's only one thing you can do with this: if you have Viewing\nHistory enabled, you can get a list of work IDs from that history, like so:\n\n.. code-block:: pycon\n\n >>> for entry in api.user.reading_history():\n ... print(entry.work_id)\n ...\n '123'\n '456'\n '789'\n # and so on\n\nYou can enable Viewing History in the settings pane.\n\nOne interesting side effect of this is that you can use it to get a list\nof works where you've left kudos:\n\n.. code-block:: python\n\n from ao3 import AO3\n from ao3.works import RestrictedWork\n\n api = AO3()\n api.login('username', 'password')\n\n for entry in api.user.reading_history():\n try:\n work = api.work(id=entry.work_id)\n except RestrictedWork:\n continue\n print(work.url + '... ', end='')\n if api.user.username in work.kudos_left_by:\n print('yes')\n else:\n print('no')\n\nWarning: this is `very` slow. It has to go back and load a page for everything\nyou've ever read. Don't use this if you're on a connection with limited\nbandwidth.\n\nThis doesn't include \"restricted\" works -- works that require you to be a\nlogged-in user to see them.\n\n(The reading page tells you when you last read something. If you cached the\nresults, and then subsequent runs only rechecked fics you'd read since the\nlast run, you could make this quite efficient. Exercise for the reader.)\n\nLicense\n*******\n\nThe project is licensed under the MIT license.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/alexwlchan/ao3", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "ao3", "package_url": "https://pypi.org/project/ao3/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/ao3/", "project_urls": { "Homepage": "https://github.com/alexwlchan/ao3" }, "release_url": "https://pypi.org/project/ao3/0.2.0/", "requires_dist": [ "beautifulsoup4 (>=4.5.3,<5)", "requests (>=2.12.4,<3)" ], "requires_python": "", "summary": "A Python API for scraping AO3 (the Archive of Our Own)", "version": "0.2.0" }, "last_serial": 2575719, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "2c16a1fe663dccf85a3572fb0f285a42", "sha256": "b7dfb793b20ccc5f78b4525365610c1ac451af62934f9192155dc29ea8154b4c" }, "downloads": -1, "filename": "ao3-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "2c16a1fe663dccf85a3572fb0f285a42", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11622, "upload_time": "2017-01-14T11:34:13", "url": "https://files.pythonhosted.org/packages/92/9d/fc62453eff4e11e13f69338d6faa3113e0d3edd87369cb7f79df29facb54/ao3-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b97cbb20a13e18eb6d362d6a5e04fa87", "sha256": "675228f30c0b4e0b8b505e60e666bd6eda31e9403ced979b5998340e1ccd8ec3" }, "downloads": -1, "filename": "ao3-0.1.0.tar.gz", "has_sig": false, "md5_digest": "b97cbb20a13e18eb6d362d6a5e04fa87", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8758, "upload_time": "2017-01-14T11:34:15", "url": "https://files.pythonhosted.org/packages/da/43/89dfee6f790e279a26face0f3d8009ca2095b894ba0bdab0770c8abc408a/ao3-0.1.0.tar.gz" } ], "0.1.1": [], "0.1.2": [ { "comment_text": "", "digests": { "md5": "e372ffe42adaed6f84827cc62ba65979", "sha256": "ca8a7ae1d113407aa8c2819d8d6343ef178b8826f9b6b569bfcbb624932f6917" }, "downloads": -1, "filename": "ao3-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "e372ffe42adaed6f84827cc62ba65979", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11627, "upload_time": "2017-01-14T11:45:53", "url": "https://files.pythonhosted.org/packages/1a/c1/75e5325282cb3cd08a8f77975b9c0437ed0db306851eb49da05be2e8bdff/ao3-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7929b95b76fd3d6a6935a59210d7e377", "sha256": "2eba76275838936b88aece4b661373619448ec2a615716c4ddab49b38c11d4a3" }, "downloads": -1, "filename": "ao3-0.1.2.tar.gz", "has_sig": false, "md5_digest": "7929b95b76fd3d6a6935a59210d7e377", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8756, "upload_time": "2017-01-14T11:45:55", "url": "https://files.pythonhosted.org/packages/72/30/9ecf8ab483258e286d435bead5757f0488f2363312c3ee021e79b54d7e20/ao3-0.1.2.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "6057c461f87f6b8d39e8945ce7e91883", "sha256": "67dc5265e7b5e9856a028adfc21a740b897e3576c4026c8a6eb4239d3a3e1ae9" }, "downloads": -1, "filename": "ao3-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "6057c461f87f6b8d39e8945ce7e91883", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11988, "upload_time": "2017-01-15T16:32:49", "url": "https://files.pythonhosted.org/packages/4f/31/9dd4cd1ed4d3ded9b58d3d2d0cfda2ef56282ac4a379e2873819ab9f2afc/ao3-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "173bb7ff4163b46069bc8e0a1859e53b", "sha256": "348c582a608b8bf463a30e2288e66b82d8bb94731e05dfcfda3f0e80e6d98b7c" }, "downloads": -1, "filename": "ao3-0.2.0.tar.gz", "has_sig": false, "md5_digest": "173bb7ff4163b46069bc8e0a1859e53b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9062, "upload_time": "2017-01-15T16:32:53", "url": "https://files.pythonhosted.org/packages/74/42/37551bfba671ad15de601b3eb67f576fd5e8e8d355a6236181012eca6088/ao3-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6057c461f87f6b8d39e8945ce7e91883", "sha256": "67dc5265e7b5e9856a028adfc21a740b897e3576c4026c8a6eb4239d3a3e1ae9" }, "downloads": -1, "filename": "ao3-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "6057c461f87f6b8d39e8945ce7e91883", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11988, "upload_time": "2017-01-15T16:32:49", "url": "https://files.pythonhosted.org/packages/4f/31/9dd4cd1ed4d3ded9b58d3d2d0cfda2ef56282ac4a379e2873819ab9f2afc/ao3-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "173bb7ff4163b46069bc8e0a1859e53b", "sha256": "348c582a608b8bf463a30e2288e66b82d8bb94731e05dfcfda3f0e80e6d98b7c" }, "downloads": -1, "filename": "ao3-0.2.0.tar.gz", "has_sig": false, "md5_digest": "173bb7ff4163b46069bc8e0a1859e53b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9062, "upload_time": "2017-01-15T16:32:53", "url": "https://files.pythonhosted.org/packages/74/42/37551bfba671ad15de601b3eb67f576fd5e8e8d355a6236181012eca6088/ao3-0.2.0.tar.gz" } ] }