Skip to content

Commit

Permalink
補入 --cookies-from-browser 參數,可從瀏覽器直接讀取 cookie 資料 (目前僅支援 chrome, edge,…
Browse files Browse the repository at this point in the history
… brave, firefox 的 default profile)。

output 參數中 將 channel、title 與 description 格式與 yt-dlp 看齊,避免將不合法的檔案字元都替換成 '_' 。
  • Loading branch information
saintliao committed Mar 19, 2023
1 parent 90aaf17 commit d71ac30
Show file tree
Hide file tree
Showing 6 changed files with 428 additions and 8 deletions.
32 changes: 29 additions & 3 deletions Info.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,32 @@ func (di *DownloadInfo) GetTimeSinceUpdated() time.Duration {
return time.Since(di.LastUpdated)
}

func replaceUnwritableFileString(str string) string {
replacer := strings.NewReplacer(
`/`, "⧸",
`\`, "⧹",
`:`, "˸",
`*`, "*",
`?`, "?",
`<`, "<",
`>`, ">",
`|`, "|",
`"`, """,
)
return replacer.Replace(str)
}

func replaceDotSign(str string) string {
idx := len(str) - 1
if idx < 0 {
return str
}
if str[idx] == '.' {
str = str[:idx] + "#" + str[idx+1:]
}
return str
}

func (fi FormatInfo) SetInfo(player_response *PlayerResponse) {
pmfr := player_response.Microformat.PlayerMicroformatRenderer
vid := player_response.VideoDetails.VideoID
Expand All @@ -339,13 +365,13 @@ func (fi FormatInfo) SetInfo(player_response *PlayerResponse) {

fi["id"] = vid
fi["url"] = url
fi["title"] = strings.TrimSpace(player_response.VideoDetails.Title)
fi["title"] = replaceUnwritableFileString(strings.TrimSpace(player_response.VideoDetails.Title))
fi["channel_id"] = player_response.VideoDetails.ChannelID
fi["channel"] = player_response.VideoDetails.Author
fi["channel"] = replaceUnwritableFileString(player_response.VideoDetails.Author)
fi["upload_date"] = startDate
fi["start_date"] = startDate
fi["publish_date"] = publishDate
fi["description"] = strings.TrimSpace(player_response.VideoDetails.ShortDescription)
fi["description"] = replaceUnwritableFileString(strings.TrimSpace(player_response.VideoDetails.ShortDescription))
}

func (mi MetaInfo) SetInfo(fi FormatInfo) {
Expand Down
Loading

0 comments on commit d71ac30

Please sign in to comment.