Skip to content

Commit a21dbe1

Browse files
authored
fix missing date in filename (#172)
1 parent 92b9895 commit a21dbe1

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

pytr/dl.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ async def dl_loop(self):
8686
else:
8787
self.log.warning(f"unmatched subscription of type '{subscription['type']}':\n{preview(response)}")
8888

89-
def dl_doc(self, doc, titleText, subtitleText, subfolder=None):
89+
def dl_doc(self, doc, titleText, subtitleText, subfolder=None, timestamp=None):
9090
"""
9191
send asynchronous request, append future with filepath to self.futures
9292
"""
@@ -98,8 +98,12 @@ def dl_doc(self, doc, titleText, subtitleText, subfolder=None):
9898
date = doc["detail"]
9999
iso_date = "-".join(date.split(".")[::-1])
100100
except KeyError:
101-
date = ""
102-
iso_date = ""
101+
if timestamp:
102+
date = timestamp.strftime("%d.%m.%Y")
103+
iso_date = timestamp.strftime("%Y-%m-%d")
104+
else:
105+
date = ""
106+
iso_date = ""
103107
doc_id = doc["id"]
104108

105109
# extract time from subtitleText

pytr/timeline.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ def process_timelineDetail(self, response, dl):
165165
"CREDIT",
166166
]:
167167
title += f" - {event['subtitle']}"
168-
dl.dl_doc(doc, title, doc.get("detail"), subfolder)
168+
dl.dl_doc(doc, title, doc.get("detail"), subfolder,
169+
datetime.fromisoformat(event['timestamp']))
169170

170171
if event["has_docs"]:
171172
self.events_with_docs.append(event)

0 commit comments

Comments
 (0)