-
-
Save trapier/82adce6c19b1a6ebc3e6ce0928790077 to your computer and use it in GitHub Desktop.
Use latest pic as background from https://twitter.com/PrimitivePic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os | |
import re | |
import subprocess | |
import tempfile | |
import time | |
import urllib.request | |
from pathlib import Path | |
TW_URL = 'https://twitter.com/PrimitivePic' | |
SUB_DIR="/Pictures/primitivepic/" | |
home = str(Path.home()) | |
page = urllib.request.urlopen(TW_URL).read().decode('utf-8') | |
pics = re.findall('pbs.twimg.com/media.*?jpg', page) | |
if pics: | |
url = pics[4] | |
image = urllib.request.urlopen('http://' + url).read() | |
tmp_file, tmp_path = tempfile.mkstemp(suffix='jpg', dir=home + SUB_DIR) | |
os.write(tmp_file, image) | |
os.close(tmp_file) | |
subprocess.call('feh --bg-max ' + tmp_path, shell=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment