livie/livie.py

42 lines
1.0 KiB
Python

"""This module does render video"""
import sys
import requests
from bs4 import BeautifulSoup
URL = 'https://yt.conocimientoslibres.ga/youtube.com/'
INPUT = sys.argv[1]
FILTER = '&type=1'
SEARCH = '%ssearch?query=%s%s' % (URL, INPUT, FILTER)
REQUEST = requests.get(SEARCH)
SOUP = BeautifulSoup(REQUEST.content, 'lxml', from_encoding=REQUEST.encoding)
# skip line loop
FIRST = True
articles = SOUP.find_all('article', class_="item-box")
for article in articles:
try:
title = article.h4.text
link = article.a['href'].replace('/', '', 1)
author = article.address.text
time = article.p.text
uploaded = article.span.text
views = article.find('div', class_="views").text
except TypeError:
continue
if FIRST:
FIRST = False
else:
print() # print skip line
# prints
print(' title: %s' % title)
print(' url: %s' % link)
print(' channel: %s' % author)
print(' uploaded: %s' % uploaded)
print(' time: %s' % time)
print(' views: %s' % views)