0

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.

Devil Ishere
  • 185
  • 1
  • 13
  • What part of your code actually plays the video? Are you asking about getting the correct URL or about playing the video from the URL? – Rotem Feb 25 '22 at 22:01
  • playing the video from url – Devil Ishere Feb 26 '22 at 04:59
  • What about the code that plays the video? Can you edit your post? Add code part like in [this post](https://stackoverflow.com/questions/66082670/python-vlc-only-works-in-python-shell). – Rotem Feb 26 '22 at 09:00
  • I don't have any code to play video but i tried every code (with appropriate edits) from the first and second link https://stackoverflow.com/questions/63203414/how-to-to-play-videos-from-the-web-using-opencv-and-python and https://stackoverflow.com/questions/37555195/is-it-possible-to-stream-video-from-https-e-g-youtube-into-python-with-ope – Devil Ishere Feb 26 '22 at 09:26
  • We may use a loop with OpenCV, but it plays only the video without the audio, and it is not going to be smooth playing like video player. Why not using `vlc.MediaPlayer`? – Rotem Feb 26 '22 at 10:16
  • Just in case you want to user OpenCV, add the code (with appropriate edits) to your post. – Rotem Feb 26 '22 at 10:19
  • Wait bro I think I got a mistake I will update it – Devil Ishere Feb 26 '22 at 10:39

1 Answers1

0

Edit: Fixed I was passing browser url instead of source url I used mpv

Devil Ishere
  • 185
  • 1
  • 13