Reputation: 335
These didn't work for me How to to play videos from the web using Opencv and python and Is it possible to stream video from https:// (e.g. YouTube) into python with OpenCV? . My program returns a link which I want to play from cli itself (preferably a module and not an executable)
Code:
from bs4 import BeautifulSoup
import requests
anime_name = 'one piece'.replace(' ', '%20')
soup = BeautifulSoup(requests.get('https://gogoanime.fi//search.html?keyword=' + anime_name).text, 'html.parser')
count = 0
number = 1
episode_number = 102
all_url = []
for k, i in enumerate(soup.find_all('a')):
if str(i.get('href')).startswith('/category') and k % 2 == 0:#it returns duplicate so using this to remove it
count += 1
print('[' + str(count) + ']', str(i.get('href'))[10:].replace('-', ' '))
all_url.append('https://gogoanime.fi//' + str(i.get('href')))
print(f'https://gogoanime.fi//{all_url[number-1][31:]}-episode-{episode_number}')
The last line returns the link it is not a file it streams the video in the browser I want to play that url using python. Tried using vlc normally but for some reason it will get stuck. Windows 7 python 3.8.8 also don't mind the number of backslash in the url the website actually made it that way.
Upvotes: 0
Views: 3691
Reputation: 335
Edit: Fixed I was passing browser url instead of source url I used mpv
Upvotes: 1