Example #1
0
func showLatest(filterFlag string, isP2PFlag bool, perPageFlag, pageFlag int) {
	if isP2PFlag {
		data, err := xrel.GetP2PReleases(perPageFlag, pageFlag, "", "", "")
		ok(err, "Failed to get latest p2p releases: ")
		if len(data.List) == 0 {
			fmt.Println("No p2p releases found.")
			os.Exit(1)
		}
		printP2PReleases(data, false, false)
	} else {
		data, err := xrel.GetLatestReleases(perPageFlag, pageFlag, filterFlag, "")
		ok(err, "Failed to get latest releases: ")
		if len(data.List) == 0 {
			fmt.Println("No releases found.")
			os.Exit(1)
		}
		printSceneReleases(data, false, false)
	}
}
Example #2
0
func browseCategory(categoryName, extInfoType string, isP2P bool, perPage, page int) {
	if isP2P {
		categoryID, err := findP2PCategoryID(categoryName)
		ok(err, "Failed to get category id: ")
		data, err := xrel.GetP2PReleases(perPage, page, categoryID, "", "")
		ok(err, "Failed to browse p2p category: ")
		if len(data.List) == 0 {
			fmt.Println("No p2p releases found.")
			os.Exit(1)
		}
		printP2PReleases(data, true, false)
	} else {
		// Currently all categories are upper case. That might change?
		categoryName = strings.ToUpper(categoryName)
		data, err := xrel.BrowseReleaseCategory(categoryName, extInfoType, perPage, page)
		ok(err, "Failed to browse scene category: ")
		if len(data.List) == 0 {
			fmt.Println("No releases found.")
			os.Exit(1)
		}
		printSceneReleases(data, true, false)
	}
}
Example #3
0
func outputExtInfoData(id string, perPageFlag, pageFlag int, isP2PFlag, infoFlag, releasesFlag, imagesFlag, videosFlag bool, rateFlag int, browseCategoryFlag string) {
	multipleItems := false

	if infoFlag || (!releasesFlag && !imagesFlag && !videosFlag && rateFlag == 0) {
		extInfo, err := xrel.GetExtInfo(id)
		ok(err, "Failed to get media information: ")
		printExtendedExtInfo(extInfo)
		multipleItems = true
	}

	if imagesFlag || videosFlag {
		if multipleItems {
			fmt.Println()
		}
		items, err := xrel.GetExtInfoMedia(id)
		itemCount := len(items)
		if err == nil && itemCount > 0 {
			if imagesFlag {
				fmt.Println("Images:")
				for i := 0; i < itemCount; i++ {
					if items[i].Type == types.MEDIA_TYPE_IMAGE {
						fmt.Println(items[i].Description + " - " + items[i].URLFull)
					}
				}
			}
			if videosFlag {
				fmt.Println("Videos:")
				for i := 0; i < itemCount; i++ {
					if items[i].Type == types.MEDIA_TYPE_VIDEO {
						fmt.Println(items[i].Description + " - " + items[i].VideoURL)
					}
				}
			}
		} else {
			fmt.Println("No images or videos found.")
		}
		multipleItems = true
	}

	if rateFlag > 0 {
		if multipleItems {
			fmt.Println()
		}
		extInfo, err := xrel.RateExtInfo(id, rateFlag)
		ok(err, "Failed to rate media: ")
		if infoFlag {
			fmt.Print("R")
		} else {
			fmt.Printf("%s [%s] r", extInfo.Title, strings.ToUpper(extInfo.Type))
		}
		fmt.Printf("ated with %s★, overall rating is %2.1f★.\n", extInfo.OwnRating, extInfo.Rating)
		multipleItems = true
	}

	if releasesFlag {
		if multipleItems {
			fmt.Println()
		}
		if isP2PFlag {
			var (
				categoryID string
				err        error
			)
			if browseCategoryFlag != "" {
				categoryID, err = findP2PCategoryID(browseCategoryFlag)
				ok(err, "Failed to get category id: ")
			}
			p2pReleases, err := xrel.GetP2PReleases(perPageFlag, pageFlag, categoryID, "", id)
			ok(err, "Failed to load p2p releases by media: ")
			printP2PReleases(p2pReleases, false, true)
		} else {
			releases, err := xrel.GetReleaseByExtInfoID(id, perPageFlag, pageFlag)
			ok(err, "Failed to load scene releases by media: ")
			printSceneReleases(releases, false, true)
		}
	}
}