1
0
Fork 0
mirror of synced 2024-06-26 18:10:26 +12:00

Refactor Erome class

This commit is contained in:
Serene-Arc 2021-03-19 22:49:25 +10:00 committed by Ali Parlakci
parent 6a1e652628
commit 902f796178
2 changed files with 8 additions and 30 deletions

View file

@ -25,23 +25,12 @@ class Erome(BaseDownloader):
if not links:
raise NotADownloadableLinkError('Erome parser could not find any links')
if len(links) == 1:
link = links.pop()
link = self._validate_url(link)
return [Resource(self.post, link)]
else:
out = []
for i, link in enumerate(links):
link = self._validate_url(link)
out.append(Resource(self.post, link))
return out
@staticmethod
def _validate_url(image):
if not re.match(r'https?://.*', image):
image = "https://" + image
return image
out = []
for link in links:
if not re.match(r'https?://.*', link):
link = 'https://' + link
out.append(Resource(self.post, link))
return out
@staticmethod
def _get_links(url: str) -> set[str]:

View file

@ -10,25 +10,14 @@ from bulkredditdownloader.site_downloaders.erome import Erome
@pytest.mark.online
@pytest.mark.parametrize(('test_url', 'expected_urls'), (
('https://www.erome.com/a/vqtPuLXh', (
'https://s6.erome.com/365/vqtPuLXh/KH2qBT99.jpg',
'https://s6.erome.com/365/vqtPuLXh/KH2qBT99_480p.mp4',
)
),
('https://www.erome.com/a/vqtPuLXh', ('https://s6.erome.com/365/vqtPuLXh/KH2qBT99_480p.mp4',)),
('https://www.erome.com/a/ORhX0FZz',
('https://s4.erome.com/355/ORhX0FZz/9IYQocM9.jpg',
'https://s4.erome.com/355/ORhX0FZz/9IYQocM9_480p.mp4',
'https://s4.erome.com/355/ORhX0FZz/9eEDc8xm.jpg',
('https://s4.erome.com/355/ORhX0FZz/9IYQocM9_480p.mp4',
'https://s4.erome.com/355/ORhX0FZz/9eEDc8xm_480p.mp4',
'https://s4.erome.com/355/ORhX0FZz/EvApC7Rp.jpg',
'https://s4.erome.com/355/ORhX0FZz/EvApC7Rp_480p.mp4',
'https://s4.erome.com/355/ORhX0FZz/LruobtMs.jpg',
'https://s4.erome.com/355/ORhX0FZz/LruobtMs_480p.mp4',
'https://s4.erome.com/355/ORhX0FZz/TJNmSUU5.jpg',
'https://s4.erome.com/355/ORhX0FZz/TJNmSUU5_480p.mp4',
'https://s4.erome.com/355/ORhX0FZz/X11Skh6Z.jpg',
'https://s4.erome.com/355/ORhX0FZz/X11Skh6Z_480p.mp4',
'https://s4.erome.com/355/ORhX0FZz/bjlTkpn7.jpg',
'https://s4.erome.com/355/ORhX0FZz/bjlTkpn7_480p.mp4')
),
))