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

Commit

Permalink
Fix the parsing of GIFs and videos
Browse files Browse the repository at this point in the history
  • Loading branch information
Mincka committed Dec 30, 2017
1 parent 0af930d commit cc5d0be
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 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.2.2"
__version__ = "0.2.3"
4 changes: 2 additions & 2 deletions dmarchiver/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def _parse_dm_media(
shutil.copyfileobj(response.raw, file)
elif len(gif_url) > 0:
media_type = MediaType.gif
media_style = gif_url[0].find('div').get('style')
media_style = gif_url[0].cssselect('div.PlayableMedia-player')[0].get('style')
media_preview_url = re.findall(r'url\(\'(.*?)\'\)', media_style)[0]
media_url = media_preview_url.replace(
'dm_gif_preview', 'dm_gif').replace('.jpg', '.mp4')
Expand All @@ -537,7 +537,7 @@ def _parse_dm_media(
shutil.copyfileobj(response.raw, file)
elif len(video_url) > 0:
media_type = MediaType.video
media_style = video_url[0].find('div').get('style')
media_style = video_url[0].cssselect('div.PlayableMedia-player')[0].get('style')
media_preview_url = re.findall(r'url\(\'(.*?)\'\)', media_style)[0]
media_url = 'https://twitter.com/i/videos/dm/' + tweet_id
video_url = 'https://mobile.twitter.com/messages/media/' + tweet_id
Expand Down

0 comments on commit cc5d0be

Please sign in to comment.