Refactor Erome class
This commit is contained in:
@@ -25,23 +25,12 @@ class Erome(BaseDownloader):
|
|||||||
if not links:
|
if not links:
|
||||||
raise NotADownloadableLinkError('Erome parser could not find any links')
|
raise NotADownloadableLinkError('Erome parser could not find any links')
|
||||||
|
|
||||||
if len(links) == 1:
|
out = []
|
||||||
link = links.pop()
|
for link in links:
|
||||||
link = self._validate_url(link)
|
if not re.match(r'https?://.*', link):
|
||||||
return [Resource(self.post, link)]
|
link = 'https://' + link
|
||||||
|
out.append(Resource(self.post, link))
|
||||||
else:
|
return out
|
||||||
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
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_links(url: str) -> set[str]:
|
def _get_links(url: str) -> set[str]:
|
||||||
|
|||||||
@@ -10,25 +10,14 @@ from bulkredditdownloader.site_downloaders.erome import Erome
|
|||||||
|
|
||||||
@pytest.mark.online
|
@pytest.mark.online
|
||||||
@pytest.mark.parametrize(('test_url', 'expected_urls'), (
|
@pytest.mark.parametrize(('test_url', 'expected_urls'), (
|
||||||
('https://www.erome.com/a/vqtPuLXh', (
|
('https://www.erome.com/a/vqtPuLXh', ('https://s6.erome.com/365/vqtPuLXh/KH2qBT99_480p.mp4',)),
|
||||||
'https://s6.erome.com/365/vqtPuLXh/KH2qBT99.jpg',
|
|
||||||
'https://s6.erome.com/365/vqtPuLXh/KH2qBT99_480p.mp4',
|
|
||||||
)
|
|
||||||
),
|
|
||||||
('https://www.erome.com/a/ORhX0FZz',
|
('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/9IYQocM9_480p.mp4',
|
|
||||||
'https://s4.erome.com/355/ORhX0FZz/9eEDc8xm.jpg',
|
|
||||||
'https://s4.erome.com/355/ORhX0FZz/9eEDc8xm_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/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/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/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/X11Skh6Z_480p.mp4',
|
||||||
'https://s4.erome.com/355/ORhX0FZz/bjlTkpn7.jpg',
|
|
||||||
'https://s4.erome.com/355/ORhX0FZz/bjlTkpn7_480p.mp4')
|
'https://s4.erome.com/355/ORhX0FZz/bjlTkpn7_480p.mp4')
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
|
|||||||
Reference in New Issue
Block a user