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
improve logging messages
sonroyaalmerol committed Mar 2, 2024
commit f2fc16acd71eb9bbd780888af4edc85784ff99d9
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ If your IPTV provider issues multiple M3U links for each connection, but you pre
## How It Works

1. **Initialization and M3U Playlist Consolidation:**
- On startup, the service loads M3U playlists from the specified URLs (M3U_URL_1, M3U_URL_2, M3U_URL_3, etc.). This usually takes a while, depending on the size of the original M3U files as it goes through each entry.
- On startup, the service loads M3U playlists from the specified URLs (M3U_URL_1, M3U_URL_2, M3U_URL_3, etc.). This usually takes a while, depending on the size of the original M3U files as it goes through each entry. The parsing process will be done in the background.
- It consolidates the playlists by merging different streams based on their stream name.
- The consolidated data will be saved in a JSON file in the data folder which will serve as its "database."
- For each unique stream name, the service aggregates the corresponding stream URLs into a consolidated M3U playlist.
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -16,13 +16,13 @@ func updateSource(ctx context.Context, m3uUrl string, index int) {
case <-ctx.Done():
return
default:
fmt.Printf("Updating M3U #%s from %d\n", m3uUrl, index)
fmt.Printf("Background process: Updating M3U #%s from %d\n", m3uUrl, index)
err := m3u.ParseM3UFromURL(m3uUrl, index)
if err != nil {
fmt.Printf("Error updating M3U: %v\n", err)
}

fmt.Printf("Updated M3U #%s from %d\n", m3uUrl, index)
fmt.Printf("Background process: Updated M3U #%s from %d\n", m3uUrl, index)

updateIntervalInHour, exists := os.LookupEnv("UPDATE_INTERVAL")
if !exists {
@@ -63,5 +63,7 @@ func main() {

// Start the server
fmt.Println("Server is running on port 8080...")
fmt.Println("Playlist Endpoint is running (`/playlist.m3u`)")
fmt.Println("Stream Endpoint is running (`/stream/{streamID}.mp4`)")
http.ListenAndServe(":8080", nil)
}