adding initial plex-posters script

This commit is contained in:
2019-11-20 02:07:22 +00:00
parent 7f961db5e0
commit f780595616
22 changed files with 305 additions and 3 deletions

BIN
plex-posters/src/plex_posters/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,67 @@
from __future__ import annotations
from typing import Type, TypeVar
import praw
import requests
__version__ = '0.1.0'
T_movie_poster_porn_scraper = TypeVar(
'T_movie_poster_porn_scraper', bound="movie_poster_porn_scraper"
)
class movie_poster_porn_scraper(object):
def __init__(self, instance: praw.Reddit) -> None:
super().__init__()
self.reddit_instance = instance
@classmethod
def create_instance(
cls: Type(T_movie_poster_porn_scraper),
client_id: str,
client_secret: str,
user_agent: str,
) -> T_movie_poster_porn_scraper:
reddit_instance = praw.Reddit(
client_id=client_id,
client_secret=client_secret,
user_agent=user_agent,
)
return cls(reddit_instance)
def get_hot_posters(
self: T_movie_poster_porn_scraper,
) -> T_movie_poster_porn_scraper:
self._poster_urls = {}
for post in self.reddit_instance.subreddit('MoviePosterPorn').hot(
limit=10
):
print(post.title)
print(post.url)
# print(dir(post))
# self._poster_urls.append(post.url)
self._poster_urls[post.title] = post.url
print(self._poster_urls)
return self
def get_posters(self: T_movie_poster_porn_scraper):
for title, url in self._poster_urls.items():
r = requests.get(url)
with open('posters/' + title + '.jpg', 'wb') as p:
p.write(r.content)
return self
inst = movie_poster_porn_scraper.create_instance(
client_id='yb7NnBPh4riSnw',
client_secret='-3Z0XUXD2XCiksfX26jORG107fA',
user_agent='Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:70.0)'
'Gecko/20100101 Firefox/70.0',
)
print(inst.reddit_instance.read_only)
inst.get_hot_posters().get_posters()

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 435 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 MiB