Giter VIP home page Giter VIP logo

Comments (6)

chrippa avatar chrippa commented on June 4, 2024

You are trying to pass a playlist to a method that expects a variant playlist (a playlist which links to varying quality playlists).

stream = HLSStream(self.session, playlisturl)

Is the way you want to use it.

from livestreamer.

athoik avatar athoik commented on June 4, 2024

Thanks @chrippa,

Just made the changes, but it seems there is an issue with relative url's.

[stream.hls][debug] Opening fd: http://hls1.webvideocore.net/hls/7zlyq17szhc0o0wwsg4o//hls/7zlyq17szhc0o0wwsg4o/6321.ts

athoik@pc:/tmp/livestreamer$ livestreamer -l debug http://streamingvideoprovider.co.uk/dymuc8e7d9cg best
[cli][info] Found matching plugin streamingvideoprovider for URL http://streamingvideoprovider.co.uk/dymuc8e7d9cg
[plugin.streamingvideoprovider][info] http://hls1.webvideocore.net/hls/7zlyq17szhc0o0wwsg4o/index.m3u8
[cli][info] Opening stream: best
[cli][debug] Pre-buffering 8192 bytes
[stream.hls][debug] Reloading playlist
[stream.hls][debug] Opening fd: http://hls1.webvideocore.net/hls/7zlyq17szhc0o0wwsg4o//hls/7zlyq17szhc0o0wwsg4o/6321.ts
[cli][error] Failed to read data from stream

Here is my plugin:

from livestreamer.stream import HLSStream
from livestreamer.plugins import Plugin, PluginError, NoStreamsError
from livestreamer.utils import urlget

from time import time
import re

class Streamingvideoprovider(Plugin):
    HLSStreamURL = "http://player.webvideocore.net/index.php?l=info&a=ajax_video_info&file={0}&rid={1}"

    @classmethod
    def can_handle_url(self, url):
        return "streamingvideoprovider.co.uk" in url

    def _get_streams(self):
        channelname = self.url.rstrip("/").rpartition("/")[2].lower()
        unixtime = str(int(time()))
        try:
            res = urlget(self.HLSStreamURL.format(channelname, unixtime))
            PlaylistURL = re.search("'(http://.+\.m3u8)'", res.text).group(1)
            self.logger.info(PlaylistURL)
            streams = {}
            streams['best'] = HLSStream(self.session, PlaylistURL)
        except IOError:
            raise NoStreamsError(self.url)

        return streams


__plugin__ = Streamingvideoprovider

from livestreamer.

chrippa avatar chrippa commented on June 4, 2024

Should be fixed with 4f72bfc.

I have not documented the plugin stuff so you couldn't know this but please don't name the stream "best", it's reserved and added automatically. When the quality does not have a name most plugins use "live" instead.

from livestreamer.

athoik avatar athoik commented on June 4, 2024

Hello,

When a url in m3u8 starts with / we must use the network location.

from urlparse import urlparse
...
    def _relative_url(self, url):
        if not url.startswith("http"):
            if url.startswith("/"):
                return "http://{0}{1}".format(urlparse(self.url).netloc, url)
            else:
                return "{0}/{1}".format(os.path.dirname(self.url), url)
        else:
            return url

With the above change streaming works. But after a while an error 500 arrives and streaming stops.

[cli][error] Error when reading from stream: Unable to open URL: http://hls1.webvideocore.net/hls/7zlyq17szhc0o0wwsg4o/21.ts (500 Server Error: Internal Server Error)

athoik@pc:/tmp/livestreamer$ livestreamer -l debug http://streamingvideoprovider.co.uk/dymuc8e7d9cg best
[cli][info] Found matching plugin streamingvideoprovider for URL http://streamingvideoprovider.co.uk/dymuc8e7d9cg
[plugin.streamingvideoprovider][info] http://hls1.webvideocore.net/hls/7zlyq17szhc0o0wwsg4o/index.m3u8
[cli][info] Opening stream: best
[cli][debug] Pre-buffering 8192 bytes
[stream.hls][debug] Reloading playlist
[stream.hls][debug] Opening fd: http://hls1.webvideocore.net/hls/7zlyq17szhc0o0wwsg4o/18.ts
[stream.hls][debug] Opening fd: http://hls1.webvideocore.net/hls/7zlyq17szhc0o0wwsg4o/19.ts
[stream.hls][debug] Opening fd: http://hls1.webvideocore.net/hls/7zlyq17szhc0o0wwsg4o/20.ts
[stream.hls][debug] Next entry: <requests.packages.urllib3.response.HTTPResponse object at 0xa4ea1ac>
[cli][info] Starting player: vlc --file-caching=5000
[cli][debug] Writing stream to output
VLC media player 2.0.3 Twoflower (revision 2.0.2-93-g77aa89e)
[0x8663908] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
Got bus address:  "unix:abstract=/tmp/dbus-xEXxdPjXBO,guid=01df72f52903cd991262d7940000002f" 
Connected to accessibility bus at:  "unix:abstract=/tmp/dbus-xEXxdPjXBO,guid=01df72f52903cd991262d7940000002f" 
Registered DEC:  true 
Registered event listener change listener:  true 
[0xb541fc08] ts demux error: MPEG-4 descriptor not found
[0xb4d4ac40] packetizer_mpeg4audio packetizer: AAC channels: 2 samplerate: 22050
[stream.hls][debug] Next entry: <requests.packages.urllib3.response.HTTPResponse object at 0xa4eaf2c>
[stream.hls][debug] Reloading playlist
[stream.hls][debug] Next entry: <requests.packages.urllib3.response.HTTPResponse object at 0xa4ea78c>
[stream.hls][debug] Opening fd: http://hls1.webvideocore.net/hls/7zlyq17szhc0o0wwsg4o/21.ts
[cli][error] Error when reading from stream: Unable to open URL: http://hls1.webvideocore.net/hls/7zlyq17szhc0o0wwsg4o/21.ts (500 Server Error: Internal Server Error)
[cli][info] Stream ended

Is this ok?

Maybe when the http error code, return by the server is 500 the streaming should continue to the next entries?

EDIT: Just show the commit 4f72bfc urljoin one-liner +1

EDIT2: Thanks for the "live" tip. I did already the change on the plugin. Soon i will fork in order to push it properly. :)

from livestreamer.

chrippa avatar chrippa commented on June 4, 2024

Hmm, this is strange, livestreamer only tries to open segments that are available in the playlist, so this means that the server lists a file that may not be available yet. :-/ cb4cfc8 handles this nicer though.

from livestreamer.

athoik avatar athoik commented on June 4, 2024

It is strange, i believe continuing to the next entries might be better.

Probably i will open open a new issue to discuss behaviour of HLS on streamingvideoprovider.

There is no issue with EXT-X-STREAM-INF. (mea culpa)

from livestreamer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.