blob: b03d1c4def0cd78a8705252617599df2edbd8cf5 (
plain)
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
41
42
43
44
45
46
|
"""This module does render video"""
import sys
import datetime
import json
import requests
URL = 'https://invidio.us'
INPUT = sys.argv[1]
SEARCH = '%s/api/v1/search?q=%s' % (URL, INPUT)
REQUEST = requests.get(SEARCH)
SD = '&itag=18&local=true'
HD = '&itag=22&local=true'
FIRST = True # skip line loop
VIDEOS = json.loads(REQUEST.content.decode('utf-8'))
for video in VIDEOS:
try:
title = video.get('title', '')
videoid = video.get('videoId', '')
author = video.get('author', '')
# Make URL
sd = '%s/latest_version?id=%s%s' % (URL, videoid, SD)
hd = '%s/latest_version?id=%s%s' % (URL, videoid, HD)
timer = video.get('lengthSeconds', '')
time = str(datetime.timedelta(seconds=timer))
publish = video.get('publishedText', '')
except TypeError:
continue
if FIRST:
FIRST = False
else:
print() # print skip line
# prints
print(' title: %s' % (title))
print(' SD: %s' % (sd))
print(' HD: %s' % (hd))
print(' HD ^ Only some videos available caused by DRM')
print(' channel: %s' % (author))
print(' time: %s' % (time))
|