Skip to content

Commit

Permalink
Get favicons for feeds, well, some/most of them
Browse files Browse the repository at this point in the history
  • Loading branch information
spudooli committed Jun 18, 2022
1 parent a7b0649 commit 1fe7e49
Show file tree
Hide file tree
Showing 43 changed files with 55 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
deploy.sh
flaskrun.sh
static/icons/


# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
43 changes: 43 additions & 0 deletions bin/get-favicons.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import mysql.connector
import os
import requests
import favicon

connection = mysql.connector.connect(
host="localhost",
user="root",
password="bobthefish",
database="reader",
)

def download(domain, id):
useragent_headers = {'User-Agent': 'Spudooli Reader/1.0 - favicon scraper - https://reader.spudooli.com/about'}
icons = favicon.get(domain, headers=useragent_headers)
icon = icons[0]

response = requests.get(icon.url, headers=useragent_headers, stream=True)
icon_file = f'{str(id)}.{icon.format}'
with open('/var/www/reader/reader/static/icons/' + icon_file, 'wb') as image:
for chunk in response.iter_content(1024):
image.write(chunk)

try:
os.system(f"convert /var/www/reader/reader/static/icons/{icon_file} -thumbnail 64x64 -flatten /var/www/reader/reader/static/icons/{id}.gif")
except:
print(f"failed to convert {icon_file}")
pass

if __name__=='__main__':

cursor = connection.cursor(buffered = True)
cursor.execute("SELECT id, websiteurl FROM feeds")

for row in cursor:
try:
print(row[1])
download(row[1], row[0])
except Exception as e:
print(e)
print("Error processing feed: --------------------------------------------" + row[1])
pass
cursor.close()
2 changes: 1 addition & 1 deletion bin/update-feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from datetime import datetime
from time import strftime

feedparser.USER_AGENT = "Spudooli Reader/1.0 - 1 subscribers - https://www.spudooli.com"
feedparser.USER_AGENT = "Spudooli Reader/1.0 - 1 subscribers - https://reader.spudooli.com/about"

if hasattr(ssl, '_create_unverified_context'):
ssl._create_default_https_context = ssl._create_unverified_context
Expand Down
3 changes: 1 addition & 2 deletions reader/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from flask import Flask
from datetime import datetime
import os


app = Flask(__name__)
Expand All @@ -13,6 +14,4 @@
def inject_now():
return {'now': datetime.utcnow()}



import reader.main
Binary file added reader/static/icons/1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/11.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/12.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/13.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/14.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/15.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/18.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/19.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/20.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/22.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/24.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/26.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/28.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/29.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/3.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/33.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/37.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/38.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/39.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/4.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/40.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/42.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/45.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/46.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reader/static/icons/47.gif
Binary file added reader/static/icons/48.gif
Binary file added reader/static/icons/49.gif
Binary file added reader/static/icons/5.gif
Binary file added reader/static/icons/52.gif
Binary file added reader/static/icons/55.gif
Binary file added reader/static/icons/6.gif
Binary file added reader/static/icons/7.gif
Binary file added reader/static/icons/8.gif
Binary file added reader/static/icons/9.gif
2 changes: 1 addition & 1 deletion reader/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ function setstar(a) {
};


setInterval("location.reload(true);", 900000);
setInterval("location.reload(true);", 300000);
2 changes: 2 additions & 0 deletions reader/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ text-decoration: underline;
.footer {
margin-top: 40px;
margin-bottom: 40px;
margin-left: 120px;
text-align: left;
}

.mydiv:hover {
Expand Down
4 changes: 3 additions & 1 deletion reader/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
{% endfor %}
{% block content %}{% endblock %}

<footer class="footer">
<footer class="footer mt-auto py-3">
<div class="container">
<span class="text-muted"><p>© Copyright {{ now.year }} <br><a href="http://www.spudooli.com" target="_blank">Spudooli Investments
Ltd</a></p></span>
</div>
</footer>
<script type="module" src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.esm.js"></script>
Expand Down
3 changes: 2 additions & 1 deletion reader/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ <h2>Feeds</h2>
<small>
<div style="float:right;">{{item[6].strftime('%A, %-d %B, %Y %-H:%M')}} </div>
</small>
<h6>{{item[5]}} </h6>
<h6><img src="/static/icons/{{ item[7] }}.gif" width="16" height="16">
{{item[5]}} </h6>
{% if item[1] == None %}<h3></h3>
{% else %}<h4><div class="star" onclick="setstar({{ item[0] }})">{% if item[8] == None %}<ion-icon id="star" name="star-outline"></ion-icon>{% else %} <ion-icon id="star" name="star"></ion-icon>{% endif %} </div> <a href="{{ item[2]}}">{{ item[1]}}</a></h4>

Expand Down

0 comments on commit 1fe7e49

Please sign in to comment.