pierre-emmanuelJ / iptv-proxy

Reverse proxy on iptv m3u and m3u8 file and xtream codes client api
GNU General Public License v3.0
535 stars 153 forks source link

Error when using M3U file or hosting M3U locally #44

Closed Olivier6767 closed 3 years ago

Olivier6767 commented 4 years ago

Hi, Thanks for the awesome tool.

I have an error when the M3U_URL points to a file or to a private URL on my home server instead of using the proviser URL.

Here is the error: panic: path segment 'IPTV_USER/IPTV_PASS/440' conflicts with existing wildcard ':id' in path '/MY_USER/MY_PASS/IPTV_USER/IPTV_PASS/440'

==> It looks like the route is made up of both usernames and passwords (the IPTV Provider credentials AND my custom credentials). It should only have my custom credentials...

Here is my configuration (by the way, I'm using TRAEFIK):

- M3U_URL=/app/iptv-proxy/playlist.m3u
- HOSTNAME=iptv.mydomain.com
- PORT=443
- HTTPS=1
- GIN_MODE=debug
- XTREAM_USER=IPTV_USER
- XTREAM_PASSWORD=IPTV_PASS
- XTREAM_BASE_URL=http://iptv.provider.com:8080
- USER=MY_USER
- PASSWORD=MY_PASS

Here is the playlist.m3u file:

#EXTM3U
#EXTINF:-1 CUID="32f046969fa415ae514d65291336ee41" tvg-id="TF1 FR" tvg-name="TF1 FR" group-title="France" tvg-logo="http://195.154.221.171/picons/tf1fr.png",TF1 FR
http://iptv.provider.com:8080/IPTV_USER/IPTV_PASS/440
#EXTINF:-1 CUID="2b9199d785af91a72d3e7d248d1102f7" tvg-id="TF1 FR" tvg-name="TF1 HD FR" group-title="France" tvg-logo="http://195.154.221.171/picons/tf1hdfr.png",TF1 HD FR
http://iptv.provider.com:8080/IPTV_USER/IPTV_PASS/441
#EXTINF:-1 CUID="3e6f47384e109a37631fe834059dc2c2" tvg-id="France 2 FR" tvg-name="France 2 FR" group-title="France" tvg-logo="http://195.154.221.171/picons/france2.png",France 2 FR
http://iptv.provider.com:8080/IPTV_USER/IPTV_PASS/438
#EXTINF:-1 CUID="e3ab745ea54cf4d674c3f2b3f2bb6d4e" tvg-id="France 2 FR" tvg-name="France 2 HD FR" group-title="France" tvg-logo="http://195.154.221.171/picons/france2hd.png",France 2 HD FR
http://iptv.provider.com:8080/IPTV_USER/IPTV_PASS/439
#EXTINF:-1 CUID="0a521ce1b250b5c30815d4fcd7ed0bf2" tvg-id="France 3 FR" tvg-name="France 3 FR" group-title="France" tvg-logo="http://195.154.221.171/picons/france3.png",France 3 FR
http://iptv.provider.com:8080/IPTV_USER/IPTV_PASS/436
#EXTINF:-1 CUID="99640dedba832437b0205a7b9c51dac2" tvg-id="France 3 FR" tvg-name="France 3 HD FR" group-title="France" tvg-logo="http://195.154.221.171/picons/france3hd.png",France 3 HD FR
http://iptv.provider.com:8080/IPTV_USER/IPTV_PASS/437
#EXTINF:-1 CUID="bbaabfbeab20fd64c7172995f237c272" tvg-id="France 4 FR" tvg-name="France 4 HD FR" group-title="France" tvg-logo="http://195.154.221.171/picons/france4hd.png",France 4 HD FR
http://iptv.provider.com:8080/IPTV_USER/IPTV_PASS/435
#EXTINF:-1 CUID="3b4a9fdfc62d276a64e55d32b896ce41" tvg-id="France 5 FR" tvg-name="France 5 FR" group-title="France" tvg-logo="http://195.154.221.171/picons/france5.png",France 5 FR
http://iptv.provider.com:8080/IPTV_USER/IPTV_PASS/434
#EXTINF:-1 CUID="8e9e8e0c4ae058bd47a22b53bd6ea0ac" tvg-id="M6 FR" tvg-name="M6 FR" group-title="France" tvg-logo="http://195.154.221.171/picons/m6fr.png",M6 FR
http://iptv.provider.com:8080/IPTV_USER/IPTV_PASS/431
#EXTINF:-1 CUID="a206ccf2100ae34973b13f390ddce487" tvg-id="M6 FR" tvg-name="M6 HD FR" group-title="France" tvg-logo="http://195.154.221.171/picons/m6hdfr.png",M6 HD FR
http://iptv.provider.com:8080/IPTV_USER/IPTV_PASS/432

The same error appears if I host the playlist.m3u file on my own server and change M3U_URL to: - M3U_URL=https://iptv_playlist.mydomain.com/playlist.m3u

However if I point M3U_URL to the provider's URL, I have no error message and the proxy functions as expected. Provider URL: M3U_URL=http://iptv.provider.com:8080/get.php?username=IPTV_USER&password=IPTV_PASS&type=m3u_plus&output=ts

The reason I want to use a local file is because I filter out the channels only to the ones I'm interested. This reduces the channel list a lot and makes it easier to use. I only remove unwanted channels from the large list from the provider, I make no other change to the m3u file content.

Here is the full error dump:

 ./iptv-proxy 
[GIN-debug] [WARNING] Now Gin requires Go 1.6 or later and Go 1.7 will be required soon.

[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /get.php                  --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(*Config).xtreamGet-fm (5 handlers)
[GIN-debug] POST   /get.php                  --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(*Config).xtreamGet-fm (5 handlers)
[GIN-debug] GET    /player_api.php           --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(*Config).xtreamPlayerAPIGET-fm (5 handlers)
[GIN-debug] POST   /player_api.php           --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(*Config).xtreamPlayerAPIPOST-fm (5 handlers)
[GIN-debug] GET    /xmltv.php                --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(*Config).xtreamXMLTV-fm (5 handlers)
[GIN-debug] GET    /MY_USER/MY_PASS/:id      --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(*Config).xtreamStream-fm (4 handlers)
[GIN-debug] GET    /live/MY_USER/MY_PASS/:id --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(*Config).xtreamStreamLive-fm (4 handlers)
[GIN-debug] GET    /movie/MY_USER/MY_PASS/:id --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(*Config).xtreamStreamMovie-fm (4 handlers)
[GIN-debug] GET    /series/MY_USER/MY_PASS/:id --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(*Config).xtreamStreamSeries-fm (4 handlers)
[GIN-debug] GET    /hlsr/:token/MY_USER/MY_PASS/:channel/:hash/:chunk --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(*Config).hlsrStream-fm (4 handlers)
[GIN-debug] GET    /iptv.m3u                 --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(*Config).getM3U-fm (5 handlers)
[GIN-debug] POST   /iptv.m3u                 --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(*Config).getM3U-fm (5 handlers)
[GIN-debug] GET    /MY_USER/MY_PASS/IPTV_USER/IPTV_PASS/440 --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(*Config).reverseProxy-fm (4 handlers)
panic: path segment 'IPTV_USER/IPTV_PASS/440' conflicts with existing wildcard ':id' in path '/MY_USER/MY_PASS/IPTV_USER/IPTV_PASS/440'

goroutine 1 [running]:
github.com/gin-gonic/gin.(*node).addRoute(0xc000067440, 0xc000027890, 0x28, 0xc0001a6fa0, 0x4, 0x4)
        /go/pkg/mod/github.com/gin-gonic/gin@v1.3.0/tree.go:196 +0xa14
github.com/gin-gonic/gin.(*Engine).addRoute(0xc00014e8c0, 0xc13523, 0x3, 0xc000027890, 0x28, 0xc0001a6fa0, 0x4, 0x4)
        /go/pkg/mod/github.com/gin-gonic/gin@v1.3.0/gin.go:252 +0x127
github.com/gin-gonic/gin.(*RouterGroup).handle(0xc000159040, 0xc13523, 0x3, 0xc000027800, 0x29, 0xc000010658, 0x1, 0x1, 0xd4d9e0, 0xc000159040)
        /go/pkg/mod/github.com/gin-gonic/gin@v1.3.0/routergroup.go:71 +0x1c4
github.com/gin-gonic/gin.(*RouterGroup).GET(...)
        /go/pkg/mod/github.com/gin-gonic/gin@v1.3.0/routergroup.go:99
github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(*Config).m3uRoutes(0xc000155620, 0xc000159040)
        /go/src/iptv-proxy/pkg/server/routes.go:86 +0x78f
github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(*Config).routes(0xc000155620, 0xc000159000)
        /go/src/iptv-proxy/pkg/server/routes.go:48 +0x95
github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(*Config).Serve(0xc000155620, 0xc000155620, 0x0)
        /go/src/iptv-proxy/pkg/server/server.go:77 +0xf5
github.com/pierre-emmanuelJ/iptv-proxy/cmd.glob..func1(0x11ae8c0, 0x11d7b50, 0x0, 0x0)
        /go/src/iptv-proxy/cmd/root.go:93 +0x62f
github.com/spf13/cobra.(*Command).execute(0x11ae8c0, 0xc0000201e0, 0x0, 0x0, 0x11ae8c0, 0xc0000201e0)
        /go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:766 +0x2aa
github.com/spf13/cobra.(*Command).ExecuteC(0x11ae8c0, 0x43d30a, 0x1172c00, 0xc000000300)
        /go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:852 +0x2ea
github.com/spf13/cobra.(*Command).Execute(...)
        /go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:800
github.com/pierre-emmanuelJ/iptv-proxy/cmd.Execute()
        /go/src/iptv-proxy/cmd/root.go:102 +0x31
main.main()
        /go/src/iptv-proxy/main.go:24 +0x20
pierre-emmanuelJ commented 4 years ago

Hello 😊 Thanks a lot for your detailed issue! Interesting problem! I’ll try to reproduce to fix it. It seems to be a problem with latest release, Just for my curiosity, can you try with 2.0.1?

Thank you

Olivier6767 commented 4 years ago

Hello, I just tried with 2.0.1 but the problem is the same, it tries to create a route with both usernames and passwords (the ones I setup for the proxy AND the ones from the IPTV provider...

Thanks for your quick reply!

pierre-emmanuelJ commented 3 years ago

Hello, I spotted your issue,

You mix xtream playlist in local (not remote playlist) and xtream service. So iptv-proxy can not detect if the playlist is on xtream format, so there is collision between xtream endpoint and playlist endpoint.

I fixed your issue in this commit: :rocket: https://github.com/pierre-emmanuelJ/iptv-proxy/commit/ba6da3be5c3dc70797d8ef3bd063662d58a64b8d Will be release ASAP!

Since you are filtering your local file, you can not use the playlist as an xtream one.

But now you can use like you do, it will work, and no more collision.