11
11
import requests
12
12
import webview
13
13
14
- FEEDLINK_RETROCOMPUTING = "https://bsky.app/profile/did:plc:tbo4hkau3p2itkar2vsnb3gp/feed/aaabo5oe7bzok"
14
+ FEEDLINK_RETROCOMPUTING = (
15
+ "https://bsky.app/profile/did:plc:tbo4hkau3p2itkar2vsnb3gp/feed/aaabo5oe7bzok"
16
+ )
15
17
16
18
# Un-comment a single key inside of FEED_ARGS and set it's value to the feed, list or search
17
19
# that you want to scroll.
18
20
FETCH_ARGS = {
19
21
# "feed_share_link": FEEDLINK_RETROCOMPUTING,
20
- # "feed_share_link": "https://bsky.app/profile/did:plc:463touruejpokvutnn5ikxb5/lists/3lbfdtahfzt2a",
22
+ # "feed_share_link": "https://bsky.app/profile/did:plc:463touruejpokvutnn5ikxb5/lists/3lbfdtahfzt2a", # pylint: disable=line-too-long
21
23
# "search_args": {"q": "Adafruit", "sort": "latest"}
22
24
"search_args" : {"q" : "#circuitpython" , "sort" : "latest" }
23
25
}
@@ -51,6 +53,7 @@ def fetch_data(feed_share_link=None, search_args=None):
51
53
the hashtag or term to search for. See bsky API docs for other supported keys.
52
54
:return: None
53
55
"""
56
+ # pylint: disable=too-many-statements,too-many-branches
54
57
if feed_share_link is None and search_args is None :
55
58
# If both inputs are None, just use retrocomputing feed.
56
59
feed_share_link = FEEDLINK_RETROCOMPUTING
@@ -62,19 +65,23 @@ def fetch_data(feed_share_link=None, search_args=None):
62
65
63
66
# if it's a feed
64
67
if "/app.bsky.feed.generator/" in FEED_AT :
65
- URL = f"https://public.api.bsky.app/xrpc/app.bsky.feed.getFeed?feed={ FEED_AT } &limit=30"
68
+ URL = (f"https://public.api.bsky.app/xrpc/app.bsky.feed.getFeed?"
69
+ f"feed={ FEED_AT } &limit=30" )
66
70
headers = {"Accept-Language" : "en" }
67
71
resp = requests .get (URL , headers = headers )
68
72
69
73
# if it's a list
70
74
elif "/app.bsky.graph.list/" in FEED_AT :
71
- URL = f"https://public.api.bsky.app/xrpc/app.bsky.feed.getListFeed?list={ FEED_AT } &limit=30"
75
+ URL = (f"https://public.api.bsky.app/xrpc/app.bsky.feed.getListFeed?"
76
+ f"list={ FEED_AT } &limit=30" )
72
77
headers = {"Accept-Language" : "en" }
73
78
resp = requests .get (URL , headers = headers )
74
79
75
80
# raise error if it's an unknown type
76
81
else :
77
- raise ValueError ("Only 'app.bsky.feed.generator' and 'app.bsky.graph.list' URIs are supported." )
82
+ raise ValueError (
83
+ "Only 'app.bsky.feed.generator' and 'app.bsky.graph.list' URIs are supported."
84
+ )
78
85
79
86
# if a search input was provided
80
87
if search_args is not None :
@@ -111,7 +118,10 @@ def fetch_data(feed_share_link=None, search_args=None):
111
118
cur_post ["image_url" ] = post ["embed" ]["images" ][0 ]["thumb" ]
112
119
elif "thumbnail" in post ["embed" ].keys ():
113
120
cur_post ["image_url" ] = post ["embed" ]["thumbnail" ]
114
- elif "external" in post ["embed" ].keys () and "thumb" in post ["embed" ]["external" ].keys ():
121
+ elif (
122
+ "external" in post ["embed" ].keys ()
123
+ and "thumb" in post ["embed" ]["external" ].keys ()
124
+ ):
115
125
cur_post ["image_url" ] = post ["embed" ]["external" ]["thumb" ]
116
126
117
127
# if we actually have an image to show
@@ -150,6 +160,7 @@ class Api:
150
160
and JS code running inside the page.
151
161
"""
152
162
163
+ # pylint: disable=no-self-use
153
164
def get_posts (self ):
154
165
"""
155
166
Fetch new posts data from Bluesky API, cache and return it.
@@ -166,11 +177,13 @@ def check_quit(self):
166
177
167
178
:return: None
168
179
"""
180
+ # pylint: disable=unnecessary-pass
169
181
pass
170
182
171
183
172
184
# create a webview and load the index.html page
173
- webview .create_window ("bsky posts" , "static/index.html" ,
174
- js_api = Api (), width = 320 , height = 240 )
185
+ webview .create_window (
186
+ "bsky posts" , "static/index.html" , js_api = Api (), width = 320 , height = 240
187
+ )
175
188
webview .start ()
176
189
# webview.start(debug=True) # use this one to enable chromium dev tools to see console.log() output from the page.
0 commit comments