diff --git a/main.go b/main.go index 3e1ce33..a047aae 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,11 @@ import ( "encoding/json" "flag" "fmt" + "io" + "log" + "net/http" "os" + "regexp" "sort" "strings" ) @@ -75,6 +79,32 @@ func CategoryFlag(name string, value Category, usage string) *Category { return &c } +func getChannelID(handle string) string { + resp, err := http.Get(fmt.Sprintf("https://www.youtube.com/%s", handle)) + if err != nil { + log.Fatal(err) + } + + body, err := io.ReadAll(resp.Body) + if err != nil { + log.Fatal(err) + } + + re := regexp.MustCompile(`]*property=["']og:url["'][^>]*content=["']([^"']+)["']`) + + results := re.FindAllStringSubmatch(string(body), -1) + parsedUrl := results[0][1] + + splits := strings.Split(parsedUrl, "/") + channelID := splits[len(splits)-1] + + return channelID +} + +func getMembersPlaylistID(channelID string) string { + return fmt.Sprintf("UUMO%s", channelID[2:]) +} + func main() { cat := CategoryFlag("category", All, "Category of videos to check against.\nValid options are all, shorts, video, livestream, membership") dumpToFile := flag.Bool("dump-to-file", false, "The program will dump the missing IDs to a file that can be used with yt-dlp") @@ -195,7 +225,7 @@ func main() { if len(missingMetadata) == 0 { fmt.Printf("Found %d IDs. No missing IDs. Congrats\n", len(existingIds)) } else { - fmt.Printf("Found %d IDs. Still missing %d IDs. For a total of %d IDs\n", len(existingIds), len(allMetadata)-(len(existingIds) - len(extraIds)), len(allMetadata)) + fmt.Printf("Found %d IDs. Still missing %d IDs. For a total of %d IDs\n", len(existingIds), len(allMetadata)-(len(existingIds)-len(extraIds)), len(allMetadata)) fmt.Println("Missing Videos are:") fmt.Println(missingMetadata)