Cigaras / IPTV.bundle

Plex plug-in that plays live streams (like IPTV) from a M3U playlist
https://forums.plex.tv/discussion/83083
GNU General Public License v3.0
974 stars 290 forks source link

HTTP referer/referrer #187

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hello, it would be possible to add one more line to add to the channels besides the user agen the referrer Here is an example of my channels in my list in vcl works perfect but I would like to put it in plex with your help

EXTINF:-0 tvg-id="ID EPG" tvg-name="NAME " tvg-logo="URL IMG LOGO" group-title="Name Group",NAME CHANNEL

EXTVLCOPT:http-referrer=URL REFERRER CHANNEL

EXTVLCOPT:http-user-agent=USER AGENT REQUIRED

URL CHANNEL

Cigaras commented 6 years ago

I doubt that it will work as there is no mention of referrer in documentation, could You give me a sample stream to test?

If no, then add a new line init.py file before line 297 yourself: HTTP.Headers['Referer'] = 'some text' or HTTP.Headers['Referrer'] = 'some text'

so the whole PlayVideo function looks like this:

@indirect
@route(PREFIX + '/playvideo.m3u8')
def PlayVideo(url, c_user_agent = None):

    # Custom User-Agent string
    if c_user_agent:
        HTTP.Headers['User-Agent'] = c_user_agent

    HTTP.Headers['Referrer'] = 'some text' # this is the new line
    return IndirectResponse(VideoClipObject, key = url)

If this works, I'll add support for the #EXTVLCOPT:http-referrer directive.

ghost commented 6 years ago

EXTINF:-1 tvg-id="LA2 TDT SD 4.sp" tvg-name="LA 2" tvg-logo="https://upload.wikimedia.org/wikipedia/commons/f/f3/Se15.png" group-title="TDT",LA 2

EXTVLCOPT:http-referrer=http://player.livesports.pw/la2/

EXTVLCOPT:http-user-agent=Mozilla/5.0 (Windows NT 10.0; …) Gecko/20100101 Firefox/59.0

http://xxedge63.livesports.pw/live/la2/chunklist.m3u8?md5=8yn90WMN-_iKb6wOluHTYA&expires=1525777298

say that the channel that the test post will not last long, that they change very often but that today works and that in this way, that the structure perfectly

ghost commented 6 years ago

I would say add something else because I did what I indicated and now it does not open or the plugin settings

Cigaras commented 6 years ago

I've made a new branch to test referer and referrer, I highly doubt that they will work, but either way, download the zip file, extract it, rename from IPTV.bundle-referer to IPTV.bundle, copy to Your plug-ins folder and use playlist You mentioned above.

ghost commented 6 years ago

I'm sorry to say that I would never work for a global list as much for a single channel as it puts the referrer of the channel that I previously indicated but each channel has a different referrer

     HTTP.Headers ['Referer'] = 'http://player.livesports.pw/la2/'      HTTP.Headers ['Referrer'] = 'http://player.livesports.pw/la2/'

these referer are only valid for a channel and even then I do not know if it would work if you want I can try it but it seems to me to throw away the time as I told you, that alone would be valid for a channel

Cigaras commented 6 years ago

I do not understand what are You saying.

If this works with single channel, I will update my plug-in so it takes referer from #EXTVLCOPT:http-referrer directive and then it will work with a whole list, but first I need to make sure it works with at least one channel.

ghost commented 6 years ago

what I say and forgive because I use xd translator is that each channel uses a different referrer and within the code it seems impossible for me to directly target the referrer instead of a tool that interprets it

Cigaras commented 6 years ago

As I said, if it works with one channel, I will make a "tool that interprets it".

ghost commented 6 years ago

ok I try and I'll tell you soon

ghost commented 6 years ago

via desktop app windows if you work but from the web browser not yet to do the test and had to modify the referrer since they change almost daily I leave a channel recently captured and functional as you are now with the tests

EXTINF:-1 tvg-id="LA2 TDT SD 4.sp" tvg-name="LA 2" tvg-logo="https://upload.wikimedia.org/wikipedia/commons/f/f3/Se15.png" group-title="TDT",LA 2 vcl

EXTVLCOPT:http-referrer=http://livesports.pw/embedna.php?file=la2&width=650&height=397

EXTVLCOPT:http-user-agent=Mozilla/5.0 (Windows NT 10.0; …) Gecko/20100101 Firefox/59.0

http://xxedge63.livesports.pw/live/la2/chunklist.m3u8?md5=5B1Iv1jmCcu_eBTaoZKqDw&expires=1527142563

ghost commented 6 years ago

As you can see it is the same channel as the other time but it has changed its referrer

Cigaras commented 6 years ago

Committed a new version to test, please download zip and rename as instructed above.

Please keep in mind that I did not test it myself, so if it breaks please check the com.plexapp.plugins.iptv.log file.

ghost commented 6 years ago

does not work and in vlc if it works is edited with note pad ++

ghost commented 6 years ago

the first time with some text if it worked in local plex now no longer

log info

https://pastebin.com/zfR3B56R

Cigaras commented 6 years ago

User Agent string in Your sample has invalid character "…", Plex can't handle it...

ghost commented 6 years ago

I had this error, I did not realize when it came to capturing the channel, it's working perfect, thank. you so much for saying that in vcl that error does not prevent you from playing the channel

Cigaras commented 6 years ago

Referer works?

ghost commented 6 years ago

yes yes it is perfect work and to say that works both locally and in the browser

ghost commented 6 years ago

https://lh3.googleusercontent.com/-VaL_9SiSgwY/WwUm8Eq3HKI/AAAAAAAAEZA/JxFoSnLSkkYwR5askthxCJVoec7BWWjHgCL0BGAYYCw/h1080/2018-05-23.png

https://lh3.googleusercontent.com/-ISgoXoswZRU/WwUkwY8U4iI/AAAAAAAAEY0/xykLPqOg5jIhNN24ZrytyNSwHkSrl3YmQCL0BGAYYCw/h1080/2018-05-23.png

I have tested several different channels with different referrer to corroborate the work and perfect

leylayx commented 6 years ago

This advance is great. I am very happy with the new version.