Esempio n. 1
0
func printAlbums(client *media.Client) {
	albums, err := client.ListAlbums("")
	if err != nil {
		panic(err)
	}
	table := make([][]string, 0)
	table = append(table, []string{
		"ID",
		"UpdatedAt",
		"Access",
		"NumPhotos",
		"BytesUsed",
		"Title",
	})
	for _, a := range albums {
		table = append(table, []string{
			a.ID,
			a.UpdatedAt.Local().Format(time.RFC3339),
			string(a.Access),
			fmt.Sprintf("%d/%d", a.NumPhotos, (a.NumPhotos + a.NumPhotosRemaining)),
			fmt.Sprintf("%d", a.BytesUsed),
			a.Title,
		})
	}
	printTable(table)
}
Esempio n. 2
0
func _rmMedia(c *cli.Context, client *media.Client, albumID string, mediaID string) {
	err := client.DeleteMedia("", albumID, mediaID)
	if err != nil {
		printError(err)
		return
	}
	fmt.Printf("Media %s was deleted.\n", mediaID)
}
Esempio n. 3
0
func _rmAlbum(c *cli.Context, client *media.Client, albumID string) {
	if !c.IsSet("force") {
		media, err := client.ListMedia("", albumID)
		if err != nil {
			printError(err)
			return
		}
		if media != nil && len(media) > 0 {
			printError(fmt.Errorf("The album still has photos. Use -f to force to remove."))
			return
		}
	}
	err := client.DeleteAlbum("", albumID)
	if err != nil {
		printError(err)
		return
	}
	fmt.Printf("Album %s was deleted.\n", albumID)
}
Esempio n. 4
0
func printMediumByID(client *media.Client, albumID string, mediaID string) {
	media, err := client.GetMedia("", albumID, mediaID)
	if err != nil {
		panic(err)
	}
	table := make([][]string, 0)
	table = append(table, []string{
		"URL",
		"Type",
		"Width",
		"Height",
		"Status",
	})
	for _, m := range media.Contents {
		table = append(table, []string{
			m.URL,
			m.Type,
			fmt.Sprintf("%d", m.Width),
			fmt.Sprintf("%d", m.Height),
		})
	}
	printTable(table)
}
Esempio n. 5
0
func printMediaByAlbumID(client *media.Client, albumID string) {
	_media, err := client.ListMedia("", albumID)
	if err != nil {
		panic(err)
	}
	table := make([][]string, 0)
	table = append(table, []string{
		"ID",
		"UpdatedAt",
		"Size",
		"Status",
		"Title",
	})
	for _, m := range _media {
		table = append(table, []string{
			fmt.Sprintf("%s/%s", m.AlbumID, m.ID),
			m.UpdatedAt.Local().Format(time.RFC3339),
			fmt.Sprintf("%d", m.Size),
			m.VideoStatus,
			m.Title,
		})
	}
	printTable(table)
}