Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Commit

Permalink
Fixes a regression bug that could prevent more than 40 conversations …
Browse files Browse the repository at this point in the history
…to be downloaded
  • Loading branch information
Mincka committed Oct 2, 2017
1 parent da570a1 commit 9a7f926
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dmarchiver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
without having to deal with the API limitations.
"""

__version__ = "0.1.9"
__version__ = "0.2.0"
20 changes: 15 additions & 5 deletions dmarchiver/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ def authenticate(self, username, password, raw_output):
if 'auth_token' in cookies:
print('Authentication succeedeed.{0}'.format(os.linesep))
else:
raise PermissionError('Your username or password was invalid. Note: DMArchiver does not support multi-factor authentication or application passwords.')
raise PermissionError(
'Your username or password was invalid. Note: DMArchiver does not support multi-factor authentication or application passwords.')

def get_threads(self, raw_output):
threads = []
Expand All @@ -309,7 +310,7 @@ def get_threads(self, raw_output):
messages_url,
headers=self._ajax_headers,
params=payload)

if raw_output:
raw_output_file.write(response.content)

Expand All @@ -322,16 +323,25 @@ def get_threads(self, raw_output):

if json['inner']['trusted']['has_more'] == False:
break

payload = {'is_trusted': 'true', 'max_entry_id': json[
'inner']['trusted']['min_entry_id']}
messages_url = self._twitter_base_url + '/inbox/paginate?is_trusted=true&max_entry_id=' + \
json['inner']['trusted']['min_entry_id']
else:
threads += json['trusted']['threads']

if json['trusted']['has_more'] == False:
break

payload = {'is_trusted': 'true', 'max_entry_id': json['inner']['trusted']['min_entry_id']}
messages_url = self._twitter_base_url + '/inbox/paginate?is_trusted=true&max_entry_id=' + json['inner']['trusted']['min_entry_id']
payload = {'is_trusted': 'true',
'max_entry_id': json['trusted']['min_entry_id']}
messages_url = self._twitter_base_url + '/inbox/paginate?is_trusted=true&max_entry_id=' + \
json['trusted']['min_entry_id']

except KeyError as e:
print('Unable to parse the list of the conversations. Maybe your account is locked or Twitter has updated the HTML code. Use -r to get the raw output and post an issue on GitHub. Exception: {0}'.format(str(e)))
print(
'Unable to fully parse the list of the conversations. Maybe your account is locked or Twitter has updated the HTML code. Use -r to get the raw output and post an issue on GitHub. Exception: {0}'.format(str(e)))
break

if raw_output:
Expand Down

0 comments on commit 9a7f926

Please sign in to comment.