diff options
Diffstat (limited to 'livie.py')
-rw-r--r-- | livie.py | 47 |
1 files changed, 21 insertions, 26 deletions
@@ -1,34 +1,29 @@ """This module does render video""" import sys -import datetime -import json import requests +from bs4 import BeautifulSoup -URL = 'https://invidio.us' +URL = 'https://yt.conocimientoslibres.ga/youtube.com/' INPUT = sys.argv[1] -SEARCH = '%s/api/v1/search?q=%s' % (URL, INPUT) +FILTER = '&type=1' +SEARCH = '%ssearch?query=%s%s' % (URL, INPUT, FILTER) REQUEST = requests.get(SEARCH) -SD = '&itag=18&local=true' -HD = '&itag=22&local=true' +SOUP = BeautifulSoup(REQUEST.content, 'lxml', from_encoding=REQUEST.encoding) +# skip line loop +FIRST = True -FIRST = True # skip line loop +articles = SOUP.find_all('article', class_="item-box") -VIDEOS = json.loads(REQUEST.content.decode('utf-8')) - -for video in VIDEOS: +for article in articles: 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) + 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 - timer = video.get('lengthSeconds', '') - time = str(datetime.timedelta(seconds=timer)) - publish = video.get('publishedText', '') except TypeError: continue @@ -38,9 +33,9 @@ for video in VIDEOS: 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)) + print(' title: %s' % title) + print(' url: %s' % link) + print(' channel: %s' % author) + print(' uploaded: %s' % uploaded) + print(' time: %s' % time) + print(' views: %s' % views) |