livie/livie.py
Jesús abbf953e64
change intance to invidio.us
Message from snopyta: Google currently rate limits IP addresses much faster, it could be that this instance wont work for a some time.
2019-10-12 19:35:02 -05:00

47 lines
1.2 KiB
Python

"""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))