livie/livie.py

37 lines
869 B
Python

"""This module does render video"""
import sys
import datetime
import json
import requests
BASE_URL = 'https://invidious.snopyta.org'
URL = BASE_URL + '/api/v1/search?q=' + sys.argv[1]
RUTA = requests.get(URL)
VIDEOS = json.loads(RUTA.content)
FIRST = True # skip line
for video in VIDEOS:
title = video.get('title', '')
videoid = video.get('videoId', '')
author = video.get('author', '')
link = BASE_URL + '/latest_version?id=' + videoid + '&itag=18&local=true'
time = str(datetime.timedelta(seconds=video.get('lengthSeconds', '')))
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}')