File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -28,9 +28,7 @@ def remove_episode(self, url: str) -> None:
28
28
break
29
29
30
30
def get_episode_list (self ) -> []:
31
- req = urllib .request .Request (self .url )
32
- req .add_header ("User-Agent" , "Mozilla/9.9 (github.com/mwhickson/tuipod) Chrome/999.9.9.9 Gecko/99990101 Firefox/999 Safari/999.9" )
33
- with urllib .request .urlopen (req ) as response :
31
+ with urllib .request .urlopen (self .url ) as response :
34
32
result = response .read ()
35
33
36
34
episodes = ET .fromstring (result )
Original file line number Diff line number Diff line change 1
1
import json
2
2
3
+ from urllib .request import build_opener , install_opener
4
+
3
5
from textual import on
4
6
from textual .app import App , ComposeResult
5
7
from textual .binding import Binding
@@ -42,6 +44,12 @@ def __init__(self):
42
44
self .current_podcast = None
43
45
self .current_episode = None
44
46
47
+ # REF: https://theorangeone.net/posts/urllib-useragent/#global-opener
48
+ # NOTE: _opener is not available for import, but it's not necessary (presumably within an app context)
49
+ opener = build_opener ()
50
+ install_opener (opener )
51
+ opener .addheaders = [("User-Agent" , "Mozilla/9.9 (github.com/mwhickson/tuipod) Chrome/999.9.9.9 Gecko/99990101 Firefox/999 Safari/999.9" )]
52
+
45
53
def compose (self ) -> ComposeResult :
46
54
yield Header (icon = "#" , show_clock = True , time_format = "%I:%M %p" )
47
55
You can’t perform that action at this time.
0 commit comments