Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 11 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,21 @@ CACHE_BACKUP_PATH=./backups
STATS_DB_PATH=./stats.db

# TTML API Configuration
# Single account (legacy, still supported):
#TTML_BEARER_TOKEN=your_bearer_token_here
# Bearer tokens are now auto-scraped from the upstream provider - only MUTs needed
# Single account:
#TTML_MEDIA_USER_TOKEN=your_media_user_token_here

# Multi-account support (comma-separated, preferred):
# Each bearer token must have a corresponding media user token in the same position
TTML_BEARER_TOKENS=token1,token2,token3
TTML_MEDIA_USER_TOKENS=media1,media2,media3
# Media User Tokens for multiple accounts - used for rate limit distribution
TTML_MEDIA_USER_TOKENS=mut1,mut2,mut3

# Token source for auto-scraping bearer tokens (web frontend URL)
TTML_TOKEN_SOURCE_URL=

# Storefront is used for both browse path (/{storefront}/browse) and API requests
# (optional, defaults to storefront location for user, falls back to 'in')
# TTML_STOREFRONT=us

TTML_STOREFRONT=us
TTML_BASE_URL=
TTML_SEARCH_PATH=
TTML_LYRICS_PATH=
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ go.work.sum
# Cache database
cache.db
stats.db
storefront_cache.json

lyrics-api-go
test.xml
/backups
/migration
/migration
134 changes: 0 additions & 134 deletions CHANGELOG.md

This file was deleted.

14 changes: 7 additions & 7 deletions cache_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,9 +645,9 @@ func cacheKeys(w http.ResponseWriter, r *http.Request) {

if count < limit {
keys = append(keys, map[string]interface{}{
"key": key,
"size": len(entry.Value),
"is_lyrics": strings.HasPrefix(key, "ttml_lyrics:"),
"key": key,
"size": len(entry.Value),
"is_lyrics": strings.HasPrefix(key, "ttml_lyrics:"),
"is_negative": strings.HasPrefix(key, "no_lyrics:"),
})
count++
Expand All @@ -658,10 +658,10 @@ func cacheKeys(w http.ResponseWriter, r *http.Request) {

w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]interface{}{
"total_keys": total,
"matched_keys": count,
"limit": limit,
"keys": keys,
"total_keys": total,
"matched_keys": count,
"limit": limit,
"keys": keys,
})
}

Expand Down
20 changes: 10 additions & 10 deletions circuitbreaker/circuitbreaker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,28 +509,28 @@ func TestCircuitBreaker_ResetClearsHalfOpenStart(t *testing.T) {

func TestCircuitBreaker_Threshold(t *testing.T) {
tests := []struct {
name string
configThreshold int
name string
configThreshold int
expectedThreshold int
}{
{
name: "Custom threshold",
configThreshold: 10,
name: "Custom threshold",
configThreshold: 10,
expectedThreshold: 10,
},
{
name: "Small threshold",
configThreshold: 2,
name: "Small threshold",
configThreshold: 2,
expectedThreshold: 2,
},
{
name: "Default threshold when zero",
configThreshold: 0,
name: "Default threshold when zero",
configThreshold: 0,
expectedThreshold: 5, // Default value
},
{
name: "Default threshold when negative",
configThreshold: -1,
name: "Default threshold when negative",
configThreshold: -1,
expectedThreshold: 5, // Default value
},
}
Expand Down
Loading
Loading