Skip to content

Commit

Permalink
added language query parameter support for m3u playlist url (#287)
Browse files Browse the repository at this point in the history
* Added language query parameter support for m3u playlist url

* Documentation added for query language support

* Contains String method from Utils package

---------

Co-authored-by: Mohammed Rabil <mail@rabil.me>
  • Loading branch information
SritharBoss and rabilrbl authored Apr 11, 2024
1 parent 2e94783 commit 0f8793b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 9 additions & 0 deletions docs/usage/iptv.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@ JioTV Go offers a convenient M3U playlist endpoint to enhance your IPTV experien
```

This will split the playlist into categories like `Movie - Kannada`, `Movie - Malayalam`, `News - English`, etc.

4. If you would like to filter only specific languages on M3U playlist, append the `l=Tamil,English,Malayalam` (comma-separated) query parameter:

```
http://localhost:5001/playlist.m3u?l=Tamil,English,Bengali
```

This will filter only the specified languages (Tamil, English and Bengali).

Available Languages to filter `Hindi, Marathi, Punjabi, Urdu, Bengali, English, Malayalam, Tamil, Gujarati, Odia, Telugu, Bhojpuri, Kannada, Assamese, Nepali, French, Other`

For both specific quality and split category, append the `q=` and `c=` query parameters:

Expand Down
9 changes: 8 additions & 1 deletion internal/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ func RenderTSHandler(c *fiber.Ctx) error {
func ChannelsHandler(c *fiber.Ctx) error {
quality := strings.TrimSpace(c.Query("q"))
isSplitCategory := strings.TrimSpace(c.Query("c")) == "split"
languages := strings.TrimSpace(c.Query("l"))
apiResponse := television.Channels()
// hostUrl should be request URL like http://localhost:5001
hostURL := strings.ToLower(c.Protocol()) + "://" + c.Hostname()
Expand All @@ -370,6 +371,11 @@ func ChannelsHandler(c *fiber.Ctx) error {
m3uContent := "#EXTM3U x-tvg-url=\"" + hostURL + "/epg.xml.gz\"\n"
logoURL := hostURL + "/jtvimage"
for _, channel := range apiResponse.Result {

if languages != "" && !utils.ContainsString(television.LanguageMap[channel.Language], strings.Split(languages, ",")) {
continue
}

var channelURL string
if quality != "" {
channelURL = fmt.Sprintf("%s/live/%s/%s.m3u8", hostURL, quality, channel.ID)
Expand Down Expand Up @@ -458,7 +464,8 @@ func FaviconHandler(c *fiber.Ctx) error {
func PlaylistHandler(c *fiber.Ctx) error {
quality := c.Query("q")
isSplitCategory := c.Query("c")
return c.Redirect("/channels?type=m3u&q="+quality+"&c="+isSplitCategory, fiber.StatusMovedPermanently)
languages := c.Query("l")
return c.Redirect("/channels?type=m3u&q="+quality+"&c="+isSplitCategory+"&l="+languages, fiber.StatusMovedPermanently)
}

// ImageHandler loads image from JioTV server
Expand Down

0 comments on commit 0f8793b

Please sign in to comment.