Example #1
0
func showUnreadFavEntries(favListName string, markAsRead bool) {
	id, err := selectFavList("", favListName)
	ok(err, "Failed to get your favorites lists: ")
	idStr := strconv.Itoa(id)
	favListEntries, err := xrel.GetFavsListEntries(idStr, true)
	ok(err, "Failed to get favorites list entries: ")
	favListEntriesCount := len(favListEntries)
	if favListEntriesCount == 0 {
		fmt.Println("You have no favorites list entries on this list.")
		os.Exit(1)
	} else {
		receivedUnreadReleases := false
		for i := 0; i < favListEntriesCount; i++ {
			entry := favListEntries[i]
			releaseCount := len(entry.Releases)
			p2pReleaseCount := len(entry.P2PReleases)
			if releaseCount != 0 || p2pReleaseCount != 0 {
				receivedUnreadReleases = true
				fmt.Println(entry.Title + " [" + strings.ToUpper(entry.Type) + "]")
				for i := 0; i < releaseCount; i++ {
					release := entry.Releases[i]
					if markAsRead {
						go xrel.MarkFavsListEntryAsRead(idStr, release.ID, true)
					}
					fmt.Println("\t[SCENE] " + release.Dirname + " (" + release.LinkURL + ")")
				}
				for i := 0; i < p2pReleaseCount; i++ {
					release := entry.P2PReleases[i]
					if markAsRead {
						go xrel.MarkFavsListEntryAsRead(idStr, release.ID, false)
					}
					fmt.Println("\t[P2P]   " + release.Dirname + " (" + release.LinkURL + ")")
				}
				fmt.Println()
			}
		}
		if !receivedUnreadReleases {
			fmt.Println("No unread releases.")
		}
	}
}
Example #2
0
func removeFavEntry(favListName string) {
	id, err := selectFavList("Please choose the list you want to remove an entry from: ", "")
	ok(err, "Failed to get your favorites lists: ")
	favListEntries, err := xrel.GetFavsListEntries(strconv.Itoa(id), false)
	ok(err, "Failed to get favorites list entries: ")
	favListEntriesCount := len(favListEntries)
	if favListEntriesCount == 0 {
		fmt.Println("You have no favorites list entries on this list.")
		os.Exit(1)
	} else {
		var entryID string
		if favListEntriesCount == 1 {
			var selection string
			fmt.Print("Do you really want to remove \"" + favListEntries[0].Title + "\"? (y/N) ")
			fmt.Scanln(&selection)
			if selection == "y" {
				entryID = favListEntries[0].ID
			} else {
				os.Exit(0)
			}
		} else {
			for i := 0; i < favListEntriesCount; i++ {
				favListEntry := favListEntries[i]
				fmt.Printf("(%d) [%s] %s\n", i+1, strings.ToUpper(favListEntry.Type), favListEntry.Title)
			}
			selection := -1
			fmt.Print("Please choose the entry you want to remove: ")
			for selection < 1 || selection > favListEntriesCount {
				fmt.Scanln(&selection)
			}
			entryID = favListEntries[selection-1].ID
		}
		fmt.Println()
		result, err := xrel.RemoveFavsListEntry(strconv.Itoa(id), entryID)
		ok(err, "Failed to remove entry: ")
		fmt.Println("Sucessfully removed \"" + result.ExtInfo.Title + "\".")
	}
}