51 lines
1.8 KiB
Markdown
51 lines
1.8 KiB
Markdown
# CLAUDE.md
|
|
|
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
|
|
## Project Overview
|
|
|
|
This is a Go-based M3U8 downloader that parses HLS (HTTP Live Streaming) playlists to extract video and audio stream metadata. The end goal of this project is to have a listening REST API take in m3u8 urls, parse them, and eventually send to a conversion service.
|
|
|
|
## Architecture
|
|
|
|
The project follows a clean separation of concerns:
|
|
|
|
- **main.go**: Entry point that demonstrates usage of the media package
|
|
- **media/**: Core package containing M3U8 parsing logic
|
|
- **types.go**: Contains the main parsing logic and data structures (`StreamSet`, `VideoURL`, `AudioURL`)
|
|
- **utils.go**: Utility functions for parsing attributes and resolution calculations
|
|
|
|
The `GetStreamMetadata()` function is the main entry point that:
|
|
1. Fetches the M3U8 master playlist via HTTP
|
|
2. Parses the content line by line
|
|
3. Extracts video streams (`#EXT-X-STREAM-INF`) and audio streams (`#EXT-X-MEDIA`)
|
|
4. Returns a `StreamSet` containing all parsed metadata
|
|
|
|
## Common Development Commands
|
|
|
|
```bash
|
|
# Build the project
|
|
go build -o m3u8-downloader
|
|
|
|
# Run the project
|
|
go run main.go
|
|
|
|
# Run with module support
|
|
go mod tidy
|
|
|
|
# Test the project (when tests are added)
|
|
go test ./...
|
|
|
|
# Format code
|
|
go fmt ./...
|
|
```
|
|
|
|
## Key Data Structures
|
|
|
|
- `StreamSet`: Root structure containing playlist URL and all streams
|
|
- `VideoURL`: Represents video stream with bandwidth, codecs, resolution, frame rate
|
|
- `AudioURL`: Represents audio stream with media type, group ID, name, and selection flags
|
|
|
|
## Error Handling
|
|
|
|
The current implementation uses `panic()` for error handling. When extending functionality, consider implementing proper error handling with returned error values following Go conventions. |