livie/livie.py
2019-07-07 18:47:47 -05:00

37 lines
921 B
Python

"""This module does render video"""
import sys
import datetime
import json
import requests
BASE_URL = 'https://invidious.snopyta.org'
ITAG = '&itag=18&local=true'
URL = "{}/api/v1/search?q={}".format(BASE_URL, sys.argv[1])
RUTA = requests.get(URL)
FIRST = True # skip line
VIDEOS = json.loads(RUTA.content)
for video in VIDEOS:
title = video.get('title', '')
videoid = video.get('videoId', '')
author = video.get('author', '')
link = "{}/latest_version?id={}{}".format(BASE_URL, videoid, ITAG)
timer = video.get('lengthSeconds', '')
time = str(datetime.timedelta(seconds=timer))
publish = video.get('publishedText', '')
if FIRST:
FIRST = False
else:
print() # print skip line
# prints
print(f' title: {title}')
print(f' url: {link}')
print(f' channel: {author}')
print(f' time: {time}')
print(f' publish: {publish}')