Skip to content

Commit cf746e4

Browse files
authored
Merge pull request #55 from MartinScharrer/timeline_V2
Timeline v2
2 parents 52f00d5 + b324b96 commit cf746e4

File tree

3 files changed

+169
-75
lines changed

3 files changed

+169
-75
lines changed

pytr/api.py

+9
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,15 @@ async def timeline_detail_order(self, order_id):
466466
async def timeline_detail_savings_plan(self, savings_plan_id):
467467
return await self.subscribe({'type': 'timelineDetail', 'savingsPlanId': savings_plan_id})
468468

469+
async def timeline_transactions(self, after=None):
470+
return await self.subscribe({'type': 'timelineTransactions', 'after': after})
471+
472+
async def timeline_activity_log(self, after=None):
473+
return await self.subscribe({'type': 'timelineActivityLog', 'after': after})
474+
475+
async def timeline_detail_v2(self, timeline_id):
476+
return await self.subscribe({'type': 'timelineDetailV2', 'id': timeline_id})
477+
469478
async def search_tags(self):
470479
return await self.subscribe({'type': 'neonSearchTags'})
471480

pytr/dl.py

+23-11
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,19 @@ def load_history(self):
6666
self.log.info('Created history file')
6767

6868
async def dl_loop(self):
69-
await self.tl.get_next_timeline(max_age_timestamp=self.since_timestamp)
69+
await self.tl.get_next_timeline_transactions(max_age_timestamp=self.since_timestamp)
7070

7171
while True:
7272
try:
7373
_subscription_id, subscription, response = await self.tr.recv()
7474
except TradeRepublicError as e:
7575
self.log.fatal(str(e))
7676

77-
if subscription['type'] == 'timeline':
78-
await self.tl.get_next_timeline(response, max_age_timestamp=self.since_timestamp)
79-
elif subscription['type'] == 'timelineDetail':
77+
if subscription['type'] == 'timelineTransactions':
78+
await self.tl.get_next_timeline_transactions(response, max_age_timestamp=self.since_timestamp)
79+
elif subscription['type'] == 'timelineActivityLog':
80+
await self.tl.get_next_timeline_activity_log(response, max_age_timestamp=self.since_timestamp)
81+
elif subscription['type'] == 'timelineDetailV2':
8082
await self.tl.timelineDetail(response, self, max_age_timestamp=self.since_timestamp)
8183
else:
8284
self.log.warning(f"unmatched subscription of type '{subscription['type']}':\n{preview(response)}")
@@ -86,17 +88,26 @@ def dl_doc(self, doc, titleText, subtitleText, subfolder=None):
8688
send asynchronous request, append future with filepath to self.futures
8789
'''
8890
doc_url = doc['action']['payload']
89-
90-
date = doc['detail']
91-
iso_date = '-'.join(date.split('.')[::-1])
91+
if subtitleText is None:
92+
subtitleText = ''
93+
94+
try:
95+
date = doc['detail']
96+
iso_date = '-'.join(date.split('.')[::-1])
97+
except KeyError:
98+
date = ''
99+
iso_date = ''
92100
doc_id = doc['id']
93101

94102
# extract time from subtitleText
95-
time = re.findall('um (\\d+:\\d+) Uhr', subtitleText)
96-
if time == []:
103+
try:
104+
time = re.findall('um (\\d+:\\d+) Uhr', subtitleText)
105+
if time == []:
106+
time = ''
107+
else:
108+
time = f' {time[0]}'
109+
except TypeError:
97110
time = ''
98-
else:
99-
time = f' {time[0]}'
100111

101112
if subfolder is not None:
102113
directory = self.output_path / subfolder
@@ -141,6 +152,7 @@ def dl_doc(self, doc, titleText, subtitleText, subfolder=None):
141152
return
142153
else:
143154
filepath = filepath_with_doc_id
155+
doc['local filepath'] = str(filepath)
144156
self.filepaths.append(filepath)
145157

146158
if filepath.is_file() is False:

0 commit comments

Comments
 (0)