Browse Source

Init

master
NaiJi 1 year ago
commit
a7b9c78c8b
  1. 1
      .gitignore
  2. 24
      LICENSE
  3. 48
      post.py

1
.gitignore

@ -0,0 +1 @@
token.dat

24
LICENSE

@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <https://unlicense.org>

48
post.py

@ -0,0 +1,48 @@
import sys
import random
import os.path as op
from urllib.parse import urlparse
import requests
from bs4 import BeautifulSoup
from mastodon import Mastodon
URL_HEAD = 'https://fancaps.net/anime/index.php?'
URL_PAGE = '&page='
URL_TRANSFER_HEAD = 'https://fancaps.net/anime/'
PAGE_AMOUNT = 20
EPISODE_IDS = ['3785', '3786', '3787', '3788',
'3789', '3790', '3791', '3792',
'3781', '3782', '3783', '3784']
def main():
# Composing initial url of a random page on random episode
episode_id = random.choice(EPISODE_IDS)
page_id = random.randint(1, PAGE_AMOUNT)
source_url = URL_HEAD + episode_id + URL_PAGE + str(page_id)
# Searching for thumbnails
resp = requests.get(source_url)
soup = BeautifulSoup(resp.text, 'lxml')
div = random.choice(soup.findAll('div', {'class': 'col-lg-3 col-md-4 col-sm-6 col-xs-6'}))
# Requesting final page by selecting a random thumbnail
resp = requests.get(URL_TRANSFER_HEAD + str(div).split('"')[5])
soup = BeautifulSoup(resp.text, 'lxml')
div = soup.find('div', {'class': 'img-holder btn-group btn-group-lg'})
# Logging in
mastodon = Mastodon(
access_token = 'token.dat',
api_base_url = 'https://udongein.xyz/'
)
file_url = str(div).split('"')[23]
media = mastodon.media_post(requests.get(file_url).content, 'image/jpeg')
toot = 'test'
mastodon.status_post(toot, media_ids=[media], visibility='unlisted')
if __name__ == '__main__':
sys.exit(main())
Loading…
Cancel
Save