diff --git a/README.md b/README.md index fec2905..3c2d289 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ proxy on xtream server api support live, vod, series and full epg :rocket: -### Example +### M3u Example original iptv m3u file ```m3u @@ -31,56 +31,94 @@ http://iptvexample.net:1234/14/test/3 http://iptvexample.net:1234/15/test/4 ``` -What proxy IPTV do +What m3u proxy IPTV do: - convert chanels url to new endpoints - convert original m3u file with new routes start proxy server example: ```Bash -poxy-server --m3u-url http://iptvexample.net/iptvm3ufile.m3u \ # or local m3u file - --port 8080 \ # port you want to expose your proxy - --hostname proxyserver.com # hostname of your machine running this proxy - ##### UNSAFE AUTH TODO ADD REAL AUTH - --user test - --password passwordtest +iptv-proxy --m3u-url http://example.com/get.php?username=user&password=pass&type=m3u_plus&output=m3u8 \ + --port 8080 \ + --hostname poxyexample.com \ + ##### UNSAFE AUTH TODO ADD REAL AUTH + --user test \ + --password passwordtest ``` - - give you the m3u file on a specific endpoint `http://poxyserver.com:8080/iptv.m3u` + that's give you the m3u file on a specific endpoint: + + `http://poxyserver.com:8080/iptv.m3u?username=test&password=passwordtest` ```m3u #EXTM3U #EXTINF:-1 tvg-ID="examplechanel1.com" tvg-name="chanel1" tvg-logo="http://ch.xyz/logo1.png" group-title="USA HD",CHANEL1-HD -http://poxyserver.com:8080/12/test/1 +http://poxyserver.com:8080/12/test/1?username=test&password=passwordtest #EXTINF:-1 tvg-ID="examplechanel2.com" tvg-name="chanel2" tvg-logo="http://ch.xyz/logo2.png" group-title="USA HD",CHANEL2-HD -http://poxyserver.com:8080/13/test/2 +http://poxyserver.com:8080/13/test/2?username=test&password=passwordtest #EXTINF:-1 tvg-ID="examplechanel3.com" tvg-name="chanel3" tvg-logo="http://ch.xyz/logo3.png" group-title="USA HD",CHANEL3-HD -http://poxyserver.com:8080/14/test/3 +http://poxyserver.com:8080/14/test/3?username=test&password=passwordtest #EXTINF:-1 tvg-ID="examplechanel4.com" tvg-name="chanel4" tvg-logo="http://ch.xyz/logo4.png" group-title="USA HD",CHANEL4-HD -http://poxyserver.com:8080/15/test/4 +http://poxyserver.com:8080/15/test/4?username=test&password=passwordtest ``` +### Xtream code server api Example + +```Bash +% iptv-proxy --m3u-url http://example.com:1234/get.php?username=user&password=pass&type=m3u_plus&output=m3u8 \ + --port 8080 \ + --hostname poxyexample.com \ + ## put xtream flags if you want to add xtream proxy + --xtream-user xtream_user \ + --xtream-password xtream_password \ + --xtream-base-url http://example.com:1234 \ + ##### UNSAFE AUTH TODO ADD REAL AUTH + --user test \ + --password passwordtest + +``` + +What xtream proxy do: + - convert xtream `xtream-user ` and `xtream-password` into new `user` and `password` + - convert `xtream-base-url` with `hostname` and `port` + + original xtream credentials: + ``` + user: xtream_user + password: xtream_password + base-url: http://example.com:1234 + ``` + new xtream credentials: + ``` + user: test + password: passwordtest + base-url: http:/poxyexample.com:8080 + ``` + + All xtream live, streams, vod, series... are poxyfied! + ## Installation ### Without Docker Download lasted [release](https://github.com/pierre-emmanuelJ/iptv-proxy/releases) -```Bash -% iptv-proxy --m3u-url http://example.com/iptv.m3u \ - --port 8080 --hostname poxyexample.com \ - ##### UNSAFE AUTH TODO ADD REAL AUTH - --user test - --password passwordtest -``` + Or +`% go install` in root repository + ```Bash -% go install -% iptv-proxy --m3u-url http://example.com/iptv.m3u \ - --port 8080 --hostname poxyexample.com \ +% iptv-proxy --m3u-url http://example.com:1234/get.php?username=user&password=pass&type=m3u_plus&output=m3u8 \ + --port 8080 \ + --hostname poxyexample.com \ + ## put xtream flags if you want to add xtream proxy + --xtream-user xtream_user \ + --xtream-password xtream_password \ + --xtream-base-url http://example.com:1234 \ ##### UNSAFE AUTH TODO ADD REAL AUTH - --user test + --user test \ --password passwordtest + ``` ### With Docker @@ -97,12 +135,18 @@ Or - 8080:8080 environment: # if you are using m3u remote file - # M3U_URL: https://example.com/iptvfile.m3u + # M3U_URL: http://example.com:1234/get.php?username=user&password=pass&type=m3u_plus&output=m3u8 M3U_URL: /root/iptv/iptv.m3u # Port to expose the IPTVs endpoints PORT: 8080 # Hostname or IP to expose the IPTVs endpoints (for machine not for docker) HOSTNAME: localhost + GIN_MODE: release + ## Xtream-code proxy configuration + ## (put these env variables if you want to add xtream proxy) + XTREAM_USER: xtream_user + XTREAM_PASSWORD: xtream_password + XTREAM_BASE_URL: "http://example.com:1234" ##### UNSAFE AUTH TODO ADD REAL AUTH USER: test PASSWORD: testpassword diff --git a/go.mod b/go.mod index 8a5bc95..942590c 100644 --- a/go.mod +++ b/go.mod @@ -8,5 +8,5 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/spf13/cobra v0.0.3 github.com/spf13/viper v1.3.1 - github.com/tellytv/go.xtream-codes v0.0.0-20190114013623-9b74dcb500e4 + github.com/tellytv/go.xtream-codes v0.0.0-20190427212115-45e8162ba888 ) diff --git a/go.sum b/go.sum index 7002939..378ecf6 100644 --- a/go.sum +++ b/go.sum @@ -54,6 +54,8 @@ github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/tellytv/go.xtream-codes v0.0.0-20190114013623-9b74dcb500e4 h1:V5xNxrc8ApVSY2uHeVXDkByVB2iAgoOcmWOOu01oATM= github.com/tellytv/go.xtream-codes v0.0.0-20190114013623-9b74dcb500e4/go.mod h1:gWtQ2uZJ49dBh4cWiFuz7Tb5ALxLB9hY1GFoz34lsGs= +github.com/tellytv/go.xtream-codes v0.0.0-20190427212115-45e8162ba888 h1:AvoYr+NW3npUjbVjBMihfM699o+xlG6N5ftA+xEjurE= +github.com/tellytv/go.xtream-codes v0.0.0-20190427212115-45e8162ba888/go.mod h1:gWtQ2uZJ49dBh4cWiFuz7Tb5ALxLB9hY1GFoz34lsGs= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 h1:EICbibRW4JNKMcY+LsWmuwob+CRS1BmdRdjphAm9mH4= github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= diff --git a/vendor/github.com/tellytv/go.xtream-codes/xtream-codes.go b/vendor/github.com/tellytv/go.xtream-codes/xtream-codes.go index ff71896..9065367 100644 --- a/vendor/github.com/tellytv/go.xtream-codes/xtream-codes.go +++ b/vendor/github.com/tellytv/go.xtream-codes/xtream-codes.go @@ -3,6 +3,7 @@ package xtreamcodes import ( "bytes" + "context" "encoding/json" "fmt" "io" @@ -11,19 +12,21 @@ import ( "strconv" ) -var userAgent = "go.xstream-codes (Go-http-client/1.1)" +var defaultUserAgent = "go.xstream-codes (Go-http-client/1.1)" // XtreamClient is the client used to communicate with a Xtream-Codes server. type XtreamClient struct { - Username string - Password string - BaseURL string + Username string + Password string + BaseURL string + UserAgent string ServerInfo ServerInfo UserInfo UserInfo // Our HTTP client to communicate with Xtream - HTTP *http.Client + HTTP *http.Client + Context context.Context // We store an internal map of Streams for use with GetStreamURL streams map[int]Stream @@ -38,11 +41,13 @@ func NewClient(username, password, baseURL string) (*XtreamClient, error) { } client := &XtreamClient{ - Username: username, - Password: password, - BaseURL: baseURL, + Username: username, + Password: password, + BaseURL: baseURL, + UserAgent: defaultUserAgent, - HTTP: http.DefaultClient, + HTTP: http.DefaultClient, + Context: context.Background(), streams: make(map[int]Stream), } @@ -64,6 +69,21 @@ func NewClient(username, password, baseURL string) (*XtreamClient, error) { return client, nil } +// NewClientWithContext returns an initialized XtreamClient with the given values. +func NewClientWithContext(ctx context.Context, username, password, baseURL string) (*XtreamClient, error) { + c, err := NewClient(username, password, baseURL) + c.Context = ctx + return c, err +} + +// NewClientWithUserAgent returns an initialized XtreamClient with the given values. +func NewClientWithUserAgent(ctx context.Context, username, password, baseURL, userAgent string) (*XtreamClient, error) { + c, err := NewClient(username, password, baseURL) + c.UserAgent = userAgent + c.Context = ctx + return c, err +} + // GetStreamURL will return a stream URL string for the given streamID and wantedFormat. func (c *XtreamClient) GetStreamURL(streamID int, wantedFormat string) (string, error) { @@ -292,7 +312,9 @@ func (c *XtreamClient) sendRequest(action string, parameters url.Values) ([]byte return nil, httpErr } - request.Header.Set("User-Agent", userAgent) + request.Header.Set("User-Agent", c.UserAgent) + + request = request.WithContext(c.Context) response, httpErr := c.HTTP.Do(request) if httpErr != nil { diff --git a/vendor/modules.txt b/vendor/modules.txt index 3abb82e..38b1965 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -55,7 +55,7 @@ github.com/spf13/jwalterweatherman github.com/spf13/pflag # github.com/spf13/viper v1.3.1 github.com/spf13/viper -# github.com/tellytv/go.xtream-codes v0.0.0-20190114013623-9b74dcb500e4 +# github.com/tellytv/go.xtream-codes v0.0.0-20190427212115-45e8162ba888 github.com/tellytv/go.xtream-codes # github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 github.com/ugorji/go/codec