File tree Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 40
40
- name : Test Daily Beast latest
41
41
if : ' !cancelled()'
42
42
run : xword-dl db
43
+ - name : Test Daily Pop latest
44
+ if : ' !cancelled()'
45
+ run : xword-dl pop
43
46
- name : Test Der Standard latest
44
47
if : ' !cancelled()'
45
48
run : xword-dl std
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ Supported outlets:
9
9
| * Atlantic* | ` atl ` | ✔️| ✔️||
10
10
| * Crossword Club* | ` club ` | ✔️| ✔️| ✔️|
11
11
| * The Daily Beast* | ` db ` | ✔️|||
12
+ | * Daily Pop* | ` pop ` | ✔️| ✔️||
12
13
| * Der Standard* | ` std ` | ✔️|| ✔️|
13
14
| * The Globe And Mail cryptic* | ` tgam ` | ✔️| ✔️| ✔️|
14
15
| * Guardian Cryptic* | ` grdc ` | ✔️|| ✔️|
Original file line number Diff line number Diff line change
1
+ import datetime
2
+ import requests
3
+ import urllib
4
+
5
+ from .compilerdownloader import CrosswordCompilerDownloader
6
+ from ..util import XWordDLException
7
+
8
+ class DailyPopDownloader (CrosswordCompilerDownloader ):
9
+ outlet = 'Daily Pop'
10
+ command = 'pop'
11
+ outlet_prefix = 'Daily Pop'
12
+
13
+ def __init__ (self , ** kwargs ):
14
+ super ().__init__ (** kwargs )
15
+
16
+ self .api_url = 'https://api.puzzlenation.com/dailyPopCrosswords/puzzles/daily/'
17
+
18
+ self .settings ['headers' ] = self .settings .get ('headers' , {})
19
+ if 'x-api-key' not in self .settings ['headers' ]:
20
+ self .settings ['headers' ]['x-api-key' ] = self .get_api_key ()
21
+
22
+ def get_api_key (self ):
23
+ res = requests .get ('http://dailypopcrosswordsweb.puzzlenation.com/crosswordSetup.js' )
24
+
25
+ api_key = None
26
+
27
+ for l in res .text .splitlines ():
28
+ if l .startswith ('const API_KEY = ' ):
29
+ api_key = l [len ('const API_KEY = "' ):- 2 ]
30
+
31
+ if not api_key :
32
+ raise XWordDLException ('Could not find Daily Pop API Key.' )
33
+
34
+ return api_key
35
+
36
+ def find_by_date (self , dt ):
37
+ url_formatted_date = dt .strftime ('%y%m%d' )
38
+ self .date = dt
39
+ return urllib .parse .urljoin (self .api_url , url_formatted_date )
40
+
41
+ def find_latest (self ):
42
+ dt = datetime .datetime .today ()
43
+ return self .find_by_date (dt )
44
+
45
+ def fetch_data (self , url ):
46
+ res = requests .get (url , headers = self .settings ['headers' ])
47
+
48
+ return res .text
You can’t perform that action at this time.
0 commit comments