-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch_all_links.py
40 lines (33 loc) · 1.29 KB
/
fetch_all_links.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import argparse
import re
from learn_video_helper import VideoDownloader
def generate_urls(base_url, num_links):
urls = []
match = re.search(r'(\d+)([a-zA-Z]*)$', base_url)
if match:
numeric_part = 1 # starting from 1
alphabetic_part = match.group(2)
prefix = base_url[:-len(match.group(0))]
for i in range(num_links):
urls.append(f"{prefix}{numeric_part + i}{alphabetic_part}")
return urls
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Download videos from Microsoft Learn.')
parser.add_argument('base_url', type=str, help='Base URL for the modules')
parser.add_argument('num_links', type=int, help='Number of links to generate')
args = parser.parse_args()
base_url = args.base_url.rstrip('/') # remove trailing slash
num_links = args.num_links
urls = generate_urls(base_url, num_links)
preferred_languages = ['en-us', 'ru-ru']
for url in urls:
print(url)
downloader = VideoDownloader(url)
downloader.run(
download_high_quality=True,
download_medium_quality=False,
download_low_quality=False,
download_audio=True,
download_captions=True,
preferred_languages=preferred_languages
)