aboutsummaryrefslogtreecommitdiffstats
path: root/livie.py
blob: 4e0ebf62ca0b3782765f9d0f6a596288852c2454 (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
"""This module does render video"""

import sys
import datetime
import json
import requests

BASE_URL = 'https://invidious.snopyta.org'
SEARCH = sys.argv[1]
ITAG = '&itag=18&local=true'
URL = f'{BASE_URL}/api/v1/search?q={SEARCH}'
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 = f'{BASE_URL}/latest_version?id={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}')