Phase 2: command screens
- /help: a short introduction with the user's default format, how to be asked every time and the limits on one line, plus buttons Commands, Account, Groups, Open app and Upgrade that switch the same message to a section. Group commands are hidden in private chats; "Add me to a group" takes their place. - /quality: Ask every time, Best that fits my limit, Best, 1080p, 720p, 480p and Audio only, with the active one checked. Free users see which qualities may go over their limit. - /history: pages of five compact buttons (site, title, format, when), a view per download with Send again, Thumbnail, Remove from history, and Clear history with a confirmation. Thumbnails are grouped under their video. Migration 00007 stores extractor, title, uploader and profile on deliveries and adds a hidden flag. - docs/SCREENS.md shows every screen in en, es and nl, generated by the language test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
6843053582
commit
123cede7f3
@@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/noderunners/dlbot/internal/media"
|
||||
"github.com/noderunners/dlbot/internal/ytdlp"
|
||||
)
|
||||
|
||||
const mb = 1 << 20
|
||||
@@ -41,3 +42,35 @@ func TestBestFit(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestBestFitFromFormatLists runs the selection on yt-dlp format lists,
|
||||
// through the same size estimates the card uses.
|
||||
func TestBestFitFromFormatLists(t *testing.T) {
|
||||
audio := ytdlp.Format{FormatID: "a", Ext: "m4a", VCodec: "none", ACodec: "mp4a", Filesize: 3 * mb}
|
||||
video := func(h int, size, approx int64, tbr float64) ytdlp.Format {
|
||||
return ytdlp.Format{FormatID: "v", Ext: "mp4", VCodec: "avc1", ACodec: "none", Height: ytdlp.Int(h),
|
||||
Filesize: ytdlp.Int(size), FilesizeAprx: ytdlp.Int(approx), TBR: ytdlp.Float(tbr)}
|
||||
}
|
||||
cases := []struct {
|
||||
name string
|
||||
duration float64
|
||||
formats []ytdlp.Format
|
||||
want media.Profile
|
||||
fits bool
|
||||
}{
|
||||
{"filesize", 300, []ytdlp.Format{audio, video(1080, 120*mb, 0, 0), video(720, 40*mb, 0, 0), video(480, 15*mb, 0, 0)}, media.P720, true},
|
||||
{"filesize_approx only", 300, []ytdlp.Format{audio, video(1080, 0, 90*mb, 0), video(720, 0, 30*mb, 0)}, media.P720, true},
|
||||
// 720p means "the best up to 720p", here the 480p format.
|
||||
{"bitrate times duration", 600, []ytdlp.Format{audio, video(1080, 0, 0, 2000), video(480, 0, 0, 500)}, media.P720, true},
|
||||
{"bitrate, only the smallest fits", 600, []ytdlp.Format{audio, video(1080, 0, 0, 2000), video(720, 0, 0, 1200), video(480, 0, 0, 500)}, media.P480, true},
|
||||
{"no size data at all", 300, []ytdlp.Format{{FormatID: "b", Ext: "mp4", VCodec: "avc1", ACodec: "mp4a", Height: 720}}, media.Best, true},
|
||||
{"too big everywhere", 300, []ytdlp.Format{audio, video(720, 400*mb, 0, 0), video(480, 200*mb, 0, 0)}, media.P480, false},
|
||||
}
|
||||
for _, c := range cases {
|
||||
info := cardInfo("https://example.com/v", &ytdlp.Info{ID: "v", Title: "T", Duration: ytdlp.Float(c.duration), Formats: c.formats})
|
||||
got, fits := BestFit(info, 50*mb)
|
||||
if got != c.want || fits != c.fits {
|
||||
t.Errorf("%s: BestFit = %s, %v; want %s, %v (sizes %v)", c.name, got, fits, c.want, c.fits, info.Sizes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user