Add support for mobile Imgur links
This commit is contained in:
@@ -34,7 +34,7 @@ class DownloadFactory:
|
|||||||
return Gfycat
|
return Gfycat
|
||||||
elif re.match(url_beginning + r'gifdeliverynetwork', url):
|
elif re.match(url_beginning + r'gifdeliverynetwork', url):
|
||||||
return GifDeliveryNetwork
|
return GifDeliveryNetwork
|
||||||
elif re.match(url_beginning + r'imgur.*', url):
|
elif re.match(url_beginning + r'(m\.)?imgur.*', url):
|
||||||
return Imgur
|
return Imgur
|
||||||
elif re.match(url_beginning + r'redgifs.com', url):
|
elif re.match(url_beginning + r'redgifs.com', url):
|
||||||
return Redgifs
|
return Redgifs
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ from bulkredditdownloader.site_downloaders.youtube import Youtube
|
|||||||
('https://m.youtube.com/watch?v=kr-FeojxzUM', Youtube),
|
('https://m.youtube.com/watch?v=kr-FeojxzUM', Youtube),
|
||||||
('https://i.imgur.com/3SKrQfK.jpg?1', Direct),
|
('https://i.imgur.com/3SKrQfK.jpg?1', Direct),
|
||||||
('https://dynasty-scans.com/system/images_images/000/017/819/original/80215103_p0.png?1612232781', Direct),
|
('https://dynasty-scans.com/system/images_images/000/017/819/original/80215103_p0.png?1612232781', Direct),
|
||||||
|
('https://m.imgur.com/a/py3RW0j', Imgur),
|
||||||
))
|
))
|
||||||
def test_factory_lever_good(test_submission_url: str, expected_class: BaseDownloader, reddit_instance: praw.Reddit):
|
def test_factory_lever_good(test_submission_url: str, expected_class: BaseDownloader, reddit_instance: praw.Reddit):
|
||||||
result = DownloadFactory.pull_lever(test_submission_url)
|
result = DownloadFactory.pull_lever(test_submission_url)
|
||||||
|
|||||||
@@ -12,21 +12,42 @@ from bulkredditdownloader.site_downloaders.imgur import Imgur
|
|||||||
|
|
||||||
@pytest.mark.online
|
@pytest.mark.online
|
||||||
@pytest.mark.parametrize(('test_url', 'expected_gen_dict', 'expected_image_dict'), (
|
@pytest.mark.parametrize(('test_url', 'expected_gen_dict', 'expected_image_dict'), (
|
||||||
('https://imgur.com/a/xWZsDDP',
|
(
|
||||||
{'num_images': '1', 'id': 'xWZsDDP', 'hash': 'xWZsDDP'},
|
'https://imgur.com/a/xWZsDDP',
|
||||||
[{'hash': 'ypa8YfS', 'title': '', 'ext': '.png', 'animated': False}]),
|
{'num_images': '1', 'id': 'xWZsDDP', 'hash': 'xWZsDDP'},
|
||||||
('https://imgur.com/gallery/IjJJdlC',
|
[
|
||||||
{'num_images': 1, 'id': 384898055, 'hash': 'IjJJdlC'},
|
{'hash': 'ypa8YfS', 'title': '', 'ext': '.png', 'animated': False}
|
||||||
[{'hash': 'CbbScDt', 'description': 'watch when he gets it', 'ext': '.gif', 'animated': True, 'has_sound': False}],
|
]
|
||||||
),
|
),
|
||||||
('https://imgur.com/a/dcc84Gt',
|
(
|
||||||
{'num_images': '4', 'id': 'dcc84Gt', 'hash': 'dcc84Gt'},
|
'https://imgur.com/gallery/IjJJdlC',
|
||||||
[
|
{'num_images': 1, 'id': 384898055, 'hash': 'IjJJdlC'},
|
||||||
{'hash': 'ylx0Kle', 'ext': '.jpg', 'title': ''},
|
[
|
||||||
{'hash': 'TdYfKbK', 'ext': '.jpg', 'title': ''},
|
{'hash': 'CbbScDt',
|
||||||
{'hash': 'pCxGbe8', 'ext': '.jpg', 'title': ''},
|
'description': 'watch when he gets it',
|
||||||
{'hash': 'TSAkikk', 'ext': '.jpg', 'title': ''},
|
'ext': '.gif',
|
||||||
]),
|
'animated': True,
|
||||||
|
'has_sound': False
|
||||||
|
}
|
||||||
|
],
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'https://imgur.com/a/dcc84Gt',
|
||||||
|
{'num_images': '4', 'id': 'dcc84Gt', 'hash': 'dcc84Gt'},
|
||||||
|
[
|
||||||
|
{'hash': 'ylx0Kle', 'ext': '.jpg', 'title': ''},
|
||||||
|
{'hash': 'TdYfKbK', 'ext': '.jpg', 'title': ''},
|
||||||
|
{'hash': 'pCxGbe8', 'ext': '.jpg', 'title': ''},
|
||||||
|
{'hash': 'TSAkikk', 'ext': '.jpg', 'title': ''},
|
||||||
|
]
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'https://m.imgur.com/a/py3RW0j',
|
||||||
|
{'num_images': '1', 'id': 'py3RW0j', 'hash': 'py3RW0j', },
|
||||||
|
[
|
||||||
|
{'hash': 'K24eQmK', 'has_sound': False, 'ext': '.jpg'}
|
||||||
|
],
|
||||||
|
),
|
||||||
))
|
))
|
||||||
def test_get_data_album(test_url: str, expected_gen_dict: dict, expected_image_dict: list[dict]):
|
def test_get_data_album(test_url: str, expected_gen_dict: dict, expected_image_dict: list[dict]):
|
||||||
result = Imgur._get_data(test_url)
|
result = Imgur._get_data(test_url)
|
||||||
|
|||||||
Reference in New Issue
Block a user