hoshsadiq / m3ufilter

ABANDONED - A tool that allows to filter specific items from an m3u filter designed for IPTV.
GNU General Public License v2.0
48 stars 18 forks source link

Build failing #10

Closed ramarnat closed 4 years ago

ramarnat commented 4 years ago

I am trying to add a small enhancement - output CUID as a hash of the url, but am having difficulty building. It fails with the error:

fatal: repository 'https://github.com/hoshsadiq/goval/' not found
fatal: repository 'https://github.com/hoshsadiq/m3u8/' not found

I don't see those, so they are probably private?

could you make them available, or add this small enhancement to the code to create a hash from the url:


index fb67b7a..6e6e6ef 100644
--- a/writer/m3u.go
+++ b/writer/m3u.go
@@ -5,6 +5,8 @@ import (
    "io"
    "strconv"
    "strings"
+   "crypto/md5"
+   "encoding/hex"
 )

 func writeM3U(w io.Writer, streams []*m3u.Stream) {
@@ -22,6 +24,12 @@ func writeM3U(w io.Writer, streams []*m3u.Stream) {
    }
 }

+func GetMD5Hash(text string) string {
+    hasher := md5.New()
+    hasher.Write([]byte(text))
+    return hex.EncodeToString(hasher.Sum(nil))
+}
+
 func getStreamExtinf(stream *m3u.Stream) []byte {
    b := &strings.Builder{}
    b.WriteString("\n")
@@ -32,6 +40,7 @@ func getStreamExtinf(stream *m3u.Stream) []byte {
        writeKV(b, "tvg-chno", stream.ChNo)
    }

+   writeKV(b, "CUID", GetMD5Hash(stream.Uri))
    writeKV(b, "tvg-id", stream.Id)
    writeKV(b, "tvg-name", stream.Name)
    writeKV(b, "group-title", stream.Group)```
hoshsadiq commented 4 years ago

My bad! I have local branches that do not rely on these dependencies, and must have gotten confused when I cleaned up my profile. I will either try and restore them at some point this week (I still have them locally).

Out of curiousity, what's the CUID for?

ramarnat commented 4 years ago

Thanks and no worries.

CUID is a way to specify a unique id. It is useful if you are using a proxy like xteve for the m3u streams and by setting the CUID to a hash of the url, helps keep the lineup in sync even if the providers change descriptions and such for the same stream.

See the Unique ID here: https://github.com/xteve-project/xTeVe-Documentation/blob/master/en/configuration.md#playlist

hoshsadiq commented 4 years ago

@ramarnat I've restored the https://github.com/hoshsadiq/goval package. I'm not sure where https://github.com/hoshsadiq/m3u8 package is coming from as that's not been in the code base for a while. Are you sure you have the latest code?

Anyway, I'll try and add CUID soonish, but happy to accept a PR otherwise!

ramarnat commented 4 years ago

It looks like the master branch compiles but fails

panic: runtime error: index out of range

goroutine 1 [running]:
github.com/hoshsadiq/m3ufilter/logger.Get.func1(0xc00010e200, 0x0, 0x141b5e5, 0x3, 0x1768460)
    /Users/ramarnat/devel/gocode/src/github.com/m3ufilter/logger/logger.go:20 +0x308
github.com/sirupsen/logrus.(*TextFormatter).Format(0xc0000ac370, 0xc0001271f0, 0xc000052330, 0xc0000b3aa8, 0x106c796, 0x140b3a0, 0xc0000b3aa8)
    /Users/ramarnat/devel/gocode/pkg/mod/github.com/sirupsen/logrus@v1.4.2/text_formatter.go:133 +0x53e
github.com/sirupsen/logrus.(*Entry).write(0xc0001271f0)
    /Users/ramarnat/devel/gocode/pkg/mod/github.com/sirupsen/logrus@v1.4.2/entry.go:255 +0x81
github.com/sirupsen/logrus.Entry.log(0xc000052300, 0xc000110300, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /Users/ramarnat/devel/gocode/pkg/mod/github.com/sirupsen/logrus@v1.4.2/entry.go:231 +0x193
github.com/sirupsen/logrus.(*Entry).Log(0xc000127180, 0x4, 0xc0000b3c48, 0x1, 0x1)
    /Users/ramarnat/devel/gocode/pkg/mod/github.com/sirupsen/logrus@v1.4.2/entry.go:268 +0xed
github.com/sirupsen/logrus.(*Entry).Logf(0xc000127180, 0xc000000004, 0x1422280, 0x18, 0xc0000b3dc0, 0x1, 0x1)
    /Users/ramarnat/devel/gocode/pkg/mod/github.com/sirupsen/logrus@v1.4.2/entry.go:314 +0xe4
github.com/sirupsen/logrus.(*Logger).Logf(0xc000052300, 0x4, 0x1422280, 0x18, 0xc0000b3dc0, 0x1, 0x1)
    /Users/ramarnat/devel/gocode/pkg/mod/github.com/sirupsen/logrus@v1.4.2/logger.go:145 +0x96
github.com/sirupsen/logrus.(*Logger).Infof(...)
    /Users/ramarnat/devel/gocode/pkg/mod/github.com/sirupsen/logrus@v1.4.2/logger.go:159
github.com/hoshsadiq/m3ufilter/m3u.GetPlaylist(0xc000011200, 0x1767810, 0x0, 0x0, 0x10da300)
    /Users/ramarnat/devel/gocode/src/github.com/m3ufilter/m3u/process.go:33 +0x848
main.run(0x7ffeefbff3cc, 0xd, 0xc00009e000, 0xc00000e010)
    /Users/ramarnat/devel/gocode/src/github.com/m3ufilter/cmd/m3u-filter/main.go:41 +0x11f
main.main()
    /Users/ramarnat/devel/gocode/src/github.com/m3ufilter/cmd/m3u-filter/main.go:30 +0x273

so I tried the v0.1-beta.2 branch, that one complains about the m3u8 package.

ramarnat commented 4 years ago

Ignore the last message on the index out of range. my mistake I think