Skip to content

Commit

Permalink
Implement #26 (stop downloading downscaled pictures)
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Larralde committed Jan 23, 2017
1 parent c7adf57 commit 4419f6f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion instaLooter/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import threading
import datetime
import os
import re


try:
Expand All @@ -21,6 +22,8 @@

class InstaDownloader(threading.Thread):

_NO_RESIZE_RX = re.compile(r'(/p[0-9]*x[0-9]*)')

def __init__(self, owner):
super(InstaDownloader, self).__init__()
self.medias = owner._medias_queue
Expand Down Expand Up @@ -78,7 +81,7 @@ def _add_metadata(self, path, metadata):
def _download_photo(self, media):
"""
"""
photo_url = media.get('display_src')
photo_url = self._NO_RESIZE_RX.sub('', media.get('display_src'))
photo_name = os.path.join(self.directory, self.owner._make_filename(media))

# save full-resolution photo
Expand Down
14 changes: 14 additions & 0 deletions tests/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import datetime
import warnings
import piexif
import PIL.Image

import instaLooter

Expand Down Expand Up @@ -103,6 +104,19 @@ def test_issue_22(self):
for char in FORBIDDEN:
self.assertNotIn(char, f)

def test_issue_26(self):
"""
Feature request by @verafide.
Checks that pictures that are downloaded are not
resized.
"""
looter = instaLooter.InstaLooter(self.tmpdir)
looter.download_post("BO0XpEshejh")
filename = "1419863760138791137.jpg"
pic = PIL.Image.open(os.path.join(self.tmpdir, filename))
self.assertEqual(pic.size, (525, 612))


def setUpModule():
warnings.simplefilter('ignore')
Expand Down

0 comments on commit 4419f6f

Please sign in to comment.