Example #1
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)
}
Example #2
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)
}