-
Notifications
You must be signed in to change notification settings - Fork 2
/
pypin.py
33 lines (24 loc) · 710 Bytes
/
pypin.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
import os
from downloader import download
from tools import *
os.chdir(os.path.dirname(os.path.abspath(__file__)))
__import__('warnings').filterwarnings("ignore")
os.makedirs('Pypin', exist_ok=1)
os.chdir('Pypin')
TYPES = [
'Video',
'GIF',
'Image',
]
NAME, HTML = getHtml(input('URL: '))
if NAME == None:
print('[ERROR] Not a Valid Pinterest URL')
exit(0)
JSON = getJson(HTML)
TYPE, MEDIA_URL = decideType(JSON)
if TYPE == None:
print('[404] Nothing Found!')
exit(0)
file_name = f'{NAME}.{MEDIA_URL.split(".")[-1]}'
print(f'Downloading {TYPES[TYPE]}: {file_name}')
download(MEDIA_URL, file_name)