Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asynchronous M3U parsing directly from URL #6

Merged
merged 33 commits into from
Mar 2, 2024
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4234d82
add context for graceful shutdown
sonroyaalmerol Mar 1, 2024
f55227c
add basic m3u tests
sonroyaalmerol Mar 1, 2024
efbf65d
remove strings import
sonroyaalmerol Mar 1, 2024
7be1087
fix expected stream url
sonroyaalmerol Mar 1, 2024
56e273d
import fmt
sonroyaalmerol Mar 1, 2024
7400a50
remove newline from expected content
sonroyaalmerol Mar 1, 2024
38fcec5
individualize sql query functions
sonroyaalmerol Mar 2, 2024
bc35489
clean up m3u package and directly connect to database
sonroyaalmerol Mar 2, 2024
c21f25a
comment out to be fixed first
sonroyaalmerol Mar 2, 2024
9df85c2
do not insert channels without titles
sonroyaalmerol Mar 2, 2024
424dde6
fix mp4_handler.go
sonroyaalmerol Mar 2, 2024
8dcfd27
fix database_test
sonroyaalmerol Mar 2, 2024
c261741
add title to insertstream error log
sonroyaalmerol Mar 2, 2024
5394e58
separate insert stream and insert url
sonroyaalmerol Mar 2, 2024
599c990
add rows next
sonroyaalmerol Mar 2, 2024
1f8c874
add more log info test
sonroyaalmerol Mar 2, 2024
6276f5d
add more log info test
sonroyaalmerol Mar 2, 2024
4002bc4
fix test error
sonroyaalmerol Mar 2, 2024
eb38c01
switch to directly accessing url
sonroyaalmerol Mar 2, 2024
2dcd36b
switch to directly accessing url
sonroyaalmerol Mar 2, 2024
db38a94
clean up downloader.go
sonroyaalmerol Mar 2, 2024
ef963ea
add USER_AGENT env var
sonroyaalmerol Mar 2, 2024
3e22d1b
make m3u parsing asynchronous
sonroyaalmerol Mar 2, 2024
f2fc16a
improve logging messages
sonroyaalmerol Mar 2, 2024
5a9a265
fix formatting
sonroyaalmerol Mar 2, 2024
8db9d85
add hadolint and golanci-lint
sonroyaalmerol Mar 2, 2024
0658fbe
fix dockerfile lint issues
sonroyaalmerol Mar 2, 2024
8c5aff9
fix golinting issues
sonroyaalmerol Mar 2, 2024
dbe8f6c
fix linting issues
sonroyaalmerol Mar 2, 2024
e233cd5
add line number to golangci-lint
sonroyaalmerol Mar 2, 2024
b5a2b3b
fix golint issue
sonroyaalmerol Mar 2, 2024
37d161d
only rollback on err
sonroyaalmerol Mar 2, 2024
d1f7a9c
fix #EXTVLCOPT
sonroyaalmerol Mar 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix expected stream url
  • Loading branch information
sonroyaalmerol authored Mar 1, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 7be1087febbccb9927021deeeaaf3ac5eb5a66db
6 changes: 5 additions & 1 deletion m3u/generate.go
Original file line number Diff line number Diff line change
@@ -9,6 +9,10 @@ import (
"net/http"
)

func generateStreamURL(baseUrl string, title string) string {
return fmt.Sprintf("%s/%s.mp4\n", baseUrl, utils.GetStreamUID(title))
}

func GenerateM3UContent(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain") // Set the Content-Type header to M3U
w.Header().Set("Access-Control-Allow-Origin", "*")
@@ -34,7 +38,7 @@ func GenerateM3UContent(w http.ResponseWriter, r *http.Request) {
}

// Write stream URL
_, err = fmt.Fprintf(w, "%s/%s.mp4\n", baseUrl, utils.GetStreamUID(stream.Title))
_, err = fmt.Fprintf(w, "%s", generateStreamURL(baseUrl, stream.Title))
if err != nil {
continue
}
6 changes: 3 additions & 3 deletions m3u/m3u_test.go
Original file line number Diff line number Diff line change
@@ -48,10 +48,10 @@ func TestGenerateM3UContent(t *testing.T) {
}

// Check the generated M3U content
expectedContent := `#EXTM3U
expectedContent := fmt.Sprintf(`#EXTM3U
#EXTINF:-1 tvg-id="1" tvg-name="TestStream" tvg-logo="http://example.com/logo.png" group-title="TestGroup",TestStream
http://localhost/stream/teststream.mp4
`
%s
`, generateStreamURL("http:///stream", "TestStream"))
if rr.Body.String() != expectedContent {
t.Errorf("handler returned unexpected body: got %v want %v",
rr.Body.String(), expectedContent)