Compare commits
No commits in common. "361494adc5d72ecb966daf69ed57e555f18467f7" and "56fab642c88775d035fcf6e9d790f192cf18cb52" have entirely different histories.
361494adc5
...
56fab642c8
@ -1,65 +0,0 @@
|
|||||||
(import (ice-9 popen)
|
|
||||||
(ice-9 rdelim)
|
|
||||||
(ice-9 regex)
|
|
||||||
(ice-9 textual-ports)
|
|
||||||
(os process))
|
|
||||||
|
|
||||||
(debug-enable 'backtrace)
|
|
||||||
|
|
||||||
(define defaults `((preferred-video-codes . ("234" "311"))
|
|
||||||
(preferred-audio-codes . ("232"))))
|
|
||||||
|
|
||||||
(define test-url "https://www.youtube.com/embed/1xVkRh7mEe0")
|
|
||||||
|
|
||||||
(define read-url
|
|
||||||
(if (not test-url)
|
|
||||||
(read-line read-url)
|
|
||||||
test-url))
|
|
||||||
|
|
||||||
(define (match-audio-format line)
|
|
||||||
(string-match "([0-9]{3,}-?).*audio only.*\\[en\\] Default\\, (high|low).*" line))
|
|
||||||
|
|
||||||
(define (match-video-format line)
|
|
||||||
(string-match "([0-9]{3,}).* ([0-9]{3,}x[0-9]{3,}).*([0-9]{2,}) \\|.* ([0-9]{1,}k).*(video only).*" line))
|
|
||||||
|
|
||||||
(define yt-dlp-port (open-input-pipe (string-append "yt-dlp --no-warnings --list-formats " read-url)))
|
|
||||||
|
|
||||||
(format #t "URL: ~a\nPREFERRED-VIDEO-CODES: ~a\nPREFERRED-AUDIO-CODES: ~a\n\n"
|
|
||||||
read-url
|
|
||||||
(cdr (assoc `preferred-video-codes defaults))
|
|
||||||
(cdr (assoc `preferred-audio-codes defaults)))
|
|
||||||
|
|
||||||
(define (lines-to-values port)
|
|
||||||
|
|
||||||
(define (iterate line out-list)
|
|
||||||
(let ((this-line (get-line port)))
|
|
||||||
|
|
||||||
(if (eof-object? this-line)
|
|
||||||
(values (reverse out-list))
|
|
||||||
(let ((video-match (match-video-format this-line))
|
|
||||||
(audio-match (match-audio-format this-line)))
|
|
||||||
|
|
||||||
(cond
|
|
||||||
(video-match
|
|
||||||
(let ((video-code (match:substring video-match 1))
|
|
||||||
(video-resolution (match:substring video-match 2))
|
|
||||||
(video-framerate (match:substring video-match 3))
|
|
||||||
(video-bitrate (match:substring video-match 4))
|
|
||||||
(video-moreinfo (match:substring video-match 5)))
|
|
||||||
|
|
||||||
(iterate this-line (acons video-code (string-append
|
|
||||||
video-resolution ","
|
|
||||||
video-framerate ","
|
|
||||||
video-bitrate) out-list))))
|
|
||||||
(audio-match
|
|
||||||
(let ((audio-code (match:substring audio-match 1))
|
|
||||||
(audio-quality (match:substring audio-match 2)))
|
|
||||||
|
|
||||||
(iterate this-line (acons audio-code audio-quality out-list))))
|
|
||||||
(else
|
|
||||||
(iterate this-line out-list)))))))
|
|
||||||
(iterate get-line '()))
|
|
||||||
|
|
||||||
;; Main
|
|
||||||
(display (lines-to-values yt-dlp-port))
|
|
||||||
(close-port yt-dlp-port)
|
|
Loading…
Reference in New Issue
Block a user