forked from mhshahin/RJ-Downloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rj_downloader.py
31 lines (27 loc) · 1.13 KB
/
rj_downloader.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
import requests
import json
import re
from subprocess import call
def get_download_link(link):
media_type = re.split(r'/', link)[3]
file_name = re.split(r'/', link)[5]
session = requests.Session()
if media_type == "podcasts":
response = session.get("https://www.radiojavan.com/podcasts/podcast_host/?id=%s" %(file_name))
url = str(json.loads(response.text)['host']) + "/media/podcast/mp3-256/" + file_name + ".mp3"
elif media_type == "mp3s":
response = session.get("https://www.radiojavan.com/mp3s/mp3_host/?id=%s" %(file_name))
url = str(json.loads(response.text)['host']) + "/media/mp3/" + file_name + ".mp3"
elif media_type == "videos":
response = session.get("https://www.radiojavan.com/videos/video_host/?id=%s" %(file_name))
url = str(json.loads(response.text)['host']) + "/media/music_video/hq/" + file_name + ".mp4"
else:
return None
return url
if __name__ == "__main__":
link = input("Enter link: ")
download_link = get_download_link(link)
if download_link:
call(["wget", download_link])
else:
print('Sorry, unsupported link!')