master
Domeniko Gentner 4 years ago
parent b15578bc7c
commit 9b4bfa34e2
  1. 5
      .gitignore
  2. 1
      Pipfile
  3. 36
      Pipfile.lock
  4. 20
      css.json
  5. 2
      mail/mail.py
  6. 15
      tw2hugo.py
  7. 7
      twitter/twitter.py

5
.gitignore vendored

@ -1,7 +1,6 @@
.idea
venv
mail/__pycache__
bearer.json
mail_credentials.json
painter/__pycache__
test.png
test.*
__pycache__/

@ -7,7 +7,6 @@ verify_ssl = true
[packages]
requests = "*"
pillow = "*"
[requires]
python_version = "3.8"

36
Pipfile.lock generated

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "d1925e0b4d1174e1ffb7d76338272b6b9aa0bf4d958c89448f76a1e35bc4007f"
"sha256": "acbc8c4e7f2f98f1059b2a93d581ef43f4aa0c9741e64e6253adff8e35fbd99e"
},
"pipfile-spec": 6,
"requires": {
@ -37,40 +37,6 @@
],
"version": "==2.10"
},
"pillow": {
"hashes": [
"sha256:006de60d7580d81f4a1a7e9f0173dc90a932e3905cc4d47ea909bc946302311a",
"sha256:0a2e8d03787ec7ad71dc18aec9367c946ef8ef50e1e78c71f743bc3a770f9fae",
"sha256:0eeeae397e5a79dc088d8297a4c2c6f901f8fb30db47795113a4a605d0f1e5ce",
"sha256:11c5c6e9b02c9dac08af04f093eb5a2f84857df70a7d4a6a6ad461aca803fb9e",
"sha256:2fb113757a369a6cdb189f8df3226e995acfed0a8919a72416626af1a0a71140",
"sha256:4b0ef2470c4979e345e4e0cc1bbac65fda11d0d7b789dbac035e4c6ce3f98adb",
"sha256:59e903ca800c8cfd1ebe482349ec7c35687b95e98cefae213e271c8c7fffa021",
"sha256:5abd653a23c35d980b332bc0431d39663b1709d64142e3652890df4c9b6970f6",
"sha256:5f9403af9c790cc18411ea398a6950ee2def2a830ad0cfe6dc9122e6d528b302",
"sha256:6b4a8fd632b4ebee28282a9fef4c341835a1aa8671e2770b6f89adc8e8c2703c",
"sha256:6c1aca8231625115104a06e4389fcd9ec88f0c9befbabd80dc206c35561be271",
"sha256:795e91a60f291e75de2e20e6bdd67770f793c8605b553cb6e4387ce0cb302e09",
"sha256:7ba0ba61252ab23052e642abdb17fd08fdcfdbbf3b74c969a30c58ac1ade7cd3",
"sha256:7c9401e68730d6c4245b8e361d3d13e1035cbc94db86b49dc7da8bec235d0015",
"sha256:81f812d8f5e8a09b246515fac141e9d10113229bc33ea073fec11403b016bcf3",
"sha256:895d54c0ddc78a478c80f9c438579ac15f3e27bf442c2a9aa74d41d0e4d12544",
"sha256:8de332053707c80963b589b22f8e0229f1be1f3ca862a932c1bcd48dafb18dd8",
"sha256:92c882b70a40c79de9f5294dc99390671e07fc0b0113d472cbea3fde15db1792",
"sha256:95edb1ed513e68bddc2aee3de66ceaf743590bf16c023fb9977adc4be15bd3f0",
"sha256:b63d4ff734263ae4ce6593798bcfee6dbfb00523c82753a3a03cbc05555a9cc3",
"sha256:bd7bf289e05470b1bc74889d1466d9ad4a56d201f24397557b6f65c24a6844b8",
"sha256:cc3ea6b23954da84dbee8025c616040d9aa5eaf34ea6895a0a762ee9d3e12e11",
"sha256:cc9ec588c6ef3a1325fa032ec14d97b7309db493782ea8c304666fb10c3bd9a7",
"sha256:d3d07c86d4efa1facdf32aa878bd508c0dc4f87c48125cc16b937baa4e5b5e11",
"sha256:d8a96747df78cda35980905bf26e72960cba6d355ace4780d4bdde3b217cdf1e",
"sha256:e38d58d9138ef972fceb7aeec4be02e3f01d383723965bfcef14d174c8ccd039",
"sha256:eb472586374dc66b31e36e14720747595c2b265ae962987261f044e5cce644b5",
"sha256:fbd922f702582cb0d71ef94442bfca57624352622d75e3be7a1e7e9360b07e72"
],
"index": "pypi",
"version": "==8.0.1"
},
"requests": {
"hashes": [
"sha256:b3559a131db72c33ee969480840fff4bb6dd111de7dd27c8ee1f820f4f00231b",

@ -1,20 +0,0 @@
{
"dimensions": {
"x": 600,
"y": 300
},
"background": {
"r": 57,
"g": 63,
"b": 77
},
"text": {
"font": "font/open-sans-v18-latin-regular.ttf",
"size": 18,
"color": {
"r": 255,
"g": 255,
"b": 255
}
}
}

@ -21,7 +21,7 @@ class mail:
if system().lower() == "windows":
path = Path("mail_credentials.json")
else:
path = Path("/etc/twpng/mail_credentials.json")
path = Path("/etc/tw2hugo/mail_credentials.json")
with path.open("r") as fp:
credentials = j_load(fp)

@ -6,11 +6,20 @@
# * _repo : https://git.tuxstash.de/gothseidank/tweet2png
# * _license : This project is under MIT License
# *********************************************************************************/
from mail import mail
from painter import painter
from twitter import twitter
from sys import exit
from platform import system
import json
twitter = twitter()
painter(twitter.get_latest_tweet(), twitter.handle())
tweet = twitter.get_latest_tweet()
handle = twitter.handle()
if system().lower() == "windows":
with open('latest_tweet.json', 'w') as fp:
json.dump(tweet, fp, indent=4, sort_keys=True)
if system().lower() == "linux":
with open('/home/git/tuxstash.de/data/latest_tweet.json', 'w') as fp:
json.dump(tweet, fp, indent=4, sort_keys=True)
exit(0)

@ -24,7 +24,7 @@ class twitter:
if system().lower() == "windows":
self.path = Path("bearer.json")
else:
self.path = Path("/etc/twpng/bearer.json")
self.path = Path("/etc/tw2hugo/twitter.json")
try:
with self.path.open('r') as fp:
@ -37,10 +37,13 @@ class twitter:
def handle(self):
return self.credentials['twitter-handle']
def output_location(self):
return self.credentials['output-location']
def get_latest_tweet(self) -> Union[str, None]:
try:
get_url = f"https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" \
f"{self.credentials['twitter-handle']}&count=1&trim_user=1"
f"{self.credentials['twitter-handle']}&count=1&tweet_mode=extended"
header = {
"Authorization": f"Bearer {self.credentials['bearer']}"

Loading…
Cancel
Save