commit
2d6e25d1ac
|
@ -32,7 +32,11 @@ class Imgur(BaseDownloader):
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def _compute_image_url(self, image: dict) -> Resource:
|
def _compute_image_url(self, image: dict) -> Resource:
|
||||||
image_url = 'https://i.imgur.com/' + image['hash'] + self._validate_extension(image['ext'])
|
ext = self._validate_extension(image['ext'])
|
||||||
|
if image.get('prefer_video', False):
|
||||||
|
ext = '.mp4'
|
||||||
|
|
||||||
|
image_url = 'https://i.imgur.com/' + image['hash'] + ext
|
||||||
return Resource(self.post, image_url, Resource.retry_download(image_url))
|
return Resource(self.post, image_url, Resource.retry_download(image_url))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -22,7 +22,10 @@ class Vidble(BaseDownloader):
|
||||||
super().__init__(post)
|
super().__init__(post)
|
||||||
|
|
||||||
def find_resources(self, authenticator: Optional[SiteAuthenticator] = None) -> list[Resource]:
|
def find_resources(self, authenticator: Optional[SiteAuthenticator] = None) -> list[Resource]:
|
||||||
res = self.get_links(self.post.url)
|
try:
|
||||||
|
res = self.get_links(self.post.url)
|
||||||
|
except AttributeError:
|
||||||
|
raise SiteDownloaderError(f'Could not read page at {self.post.url}')
|
||||||
if not res:
|
if not res:
|
||||||
raise SiteDownloaderError(rf'No resources found at {self.post.url}')
|
raise SiteDownloaderError(rf'No resources found at {self.post.url}')
|
||||||
res = [Resource(self.post, r, Resource.retry_download(r)) for r in res]
|
res = [Resource(self.post, r, Resource.retry_download(r)) for r in res]
|
||||||
|
@ -30,6 +33,9 @@ class Vidble(BaseDownloader):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_links(url: str) -> set[str]:
|
def get_links(url: str) -> set[str]:
|
||||||
|
if not re.search(r'vidble.com/(show/|album/|watch\?v)', url):
|
||||||
|
url = re.sub(r'/(\w*?)$', r'/show/\1', url)
|
||||||
|
|
||||||
page = requests.get(url)
|
page = requests.get(url)
|
||||||
soup = bs4.BeautifulSoup(page.text, 'html.parser')
|
soup = bs4.BeautifulSoup(page.text, 'html.parser')
|
||||||
content_div = soup.find('div', attrs={'id': 'ContentPlaceHolder1_divContent'})
|
content_div = soup.find('div', attrs={'id': 'ContentPlaceHolder1_divContent'})
|
||||||
|
|
|
@ -4,7 +4,7 @@ description_file = README.md
|
||||||
description_content_type = text/markdown
|
description_content_type = text/markdown
|
||||||
home_page = https://github.com/aliparlakci/bulk-downloader-for-reddit
|
home_page = https://github.com/aliparlakci/bulk-downloader-for-reddit
|
||||||
keywords = reddit, download, archive
|
keywords = reddit, download, archive
|
||||||
version = 2.4.0
|
version = 2.4.1
|
||||||
author = Ali Parlakci
|
author = Ali Parlakci
|
||||||
author_email = parlakciali@gmail.com
|
author_email = parlakciali@gmail.com
|
||||||
maintainer = Serene Arc
|
maintainer = Serene Arc
|
||||||
|
|
|
@ -111,7 +111,7 @@ def test_imgur_extension_validation_bad(test_extension: str):
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'https://imgur.com/gallery/IjJJdlC',
|
'https://imgur.com/gallery/IjJJdlC',
|
||||||
('7227d4312a9779b74302724a0cfa9081',),
|
('740b006cf9ec9d6f734b6e8f5130bdab',),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'https://imgur.com/a/dcc84Gt',
|
'https://imgur.com/a/dcc84Gt',
|
||||||
|
@ -142,6 +142,14 @@ def test_imgur_extension_validation_bad(test_extension: str):
|
||||||
'https://imgur.com/ubYwpbk.GIFV',
|
'https://imgur.com/ubYwpbk.GIFV',
|
||||||
('d4a774aac1667783f9ed3a1bd02fac0c',),
|
('d4a774aac1667783f9ed3a1bd02fac0c',),
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
'https://i.imgur.com/j1CNCZY.gifv',
|
||||||
|
('58e7e6d972058c18b7ecde910ca147e3',),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'https://i.imgur.com/uTvtQsw.gifv',
|
||||||
|
('46c86533aa60fc0e09f2a758513e3ac2',),
|
||||||
|
),
|
||||||
))
|
))
|
||||||
def test_find_resources(test_url: str, expected_hashes: list[str]):
|
def test_find_resources(test_url: str, expected_hashes: list[str]):
|
||||||
mock_download = Mock()
|
mock_download = Mock()
|
||||||
|
|
|
@ -33,6 +33,9 @@ def test_change_med_url(test_url: str, expected: str):
|
||||||
('https://vidble.com/watch?v=0q4nWakqM6kzQWxlePD8N62Dsflev0N9', {
|
('https://vidble.com/watch?v=0q4nWakqM6kzQWxlePD8N62Dsflev0N9', {
|
||||||
'https://www.vidble.com/0q4nWakqM6kzQWxlePD8N62Dsflev0N9.mp4',
|
'https://www.vidble.com/0q4nWakqM6kzQWxlePD8N62Dsflev0N9.mp4',
|
||||||
}),
|
}),
|
||||||
|
('https://www.vidble.com/pHuwWkOcEb', {
|
||||||
|
'https://www.vidble.com/pHuwWkOcEb.jpg',
|
||||||
|
}),
|
||||||
))
|
))
|
||||||
def test_get_links(test_url: str, expected: set[str]):
|
def test_get_links(test_url: str, expected: set[str]):
|
||||||
results = Vidble.get_links(test_url)
|
results = Vidble.get_links(test_url)
|
||||||
|
@ -40,21 +43,24 @@ def test_get_links(test_url: str, expected: set[str]):
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(('test_url', 'expected_hashes'), (
|
@pytest.mark.parametrize(('test_url', 'expected_hashes'), (
|
||||||
('https://www.vidble.com/show/UxsvAssYe5', {
|
('https://www.vidble.com/show/UxsvAssYe5', {
|
||||||
'0ef2f8e0e0b45936d2fb3e6fbdf67e28',
|
'0ef2f8e0e0b45936d2fb3e6fbdf67e28',
|
||||||
}),
|
}),
|
||||||
('https://vidble.com/show/RDFbznUvcN', {
|
('https://vidble.com/show/RDFbznUvcN', {
|
||||||
'c2dd30a71e32369c50eed86f86efff58',
|
'c2dd30a71e32369c50eed86f86efff58',
|
||||||
}),
|
}),
|
||||||
('https://vidble.com/album/h0jTLs6B', {
|
('https://vidble.com/album/h0jTLs6B', {
|
||||||
'3b3cba02e01c91f9858a95240b942c71',
|
'3b3cba02e01c91f9858a95240b942c71',
|
||||||
'dd6ecf5fc9e936f9fb614eb6a0537f99',
|
'dd6ecf5fc9e936f9fb614eb6a0537f99',
|
||||||
'b31a942cd8cdda218ed547bbc04c3a27',
|
'b31a942cd8cdda218ed547bbc04c3a27',
|
||||||
'6f77c570b451eef4222804bd52267481',
|
'6f77c570b451eef4222804bd52267481',
|
||||||
}),
|
}),
|
||||||
('https://vidble.com/watch?v=0q4nWakqM6kzQWxlePD8N62Dsflev0N9', {
|
('https://vidble.com/watch?v=0q4nWakqM6kzQWxlePD8N62Dsflev0N9', {
|
||||||
'cebe9d5f24dba3b0443e5097f160ca83',
|
'cebe9d5f24dba3b0443e5097f160ca83',
|
||||||
}),
|
}),
|
||||||
|
('https://www.vidble.com/pHuwWkOcEb', {
|
||||||
|
'585f486dd0b2f23a57bddbd5bf185bc7',
|
||||||
|
}),
|
||||||
))
|
))
|
||||||
def test_find_resources(test_url: str, expected_hashes: set[str]):
|
def test_find_resources(test_url: str, expected_hashes: set[str]):
|
||||||
mock_download = Mock()
|
mock_download = Mock()
|
||||||
|
|
Loading…
Reference in a new issue