예제 #1
0
func addonZip(ctx *gin.Context, user string, repository string, lastReleaseTag string) {
	release := getReleaseByTag(user, repository, lastReleaseTag)
	// if there a release with an asset that matches a addon zip, use it
	if release != nil {
		client := github.NewClient(nil)
		assets, _, _ := client.Repositories.ListReleaseAssets(user, repository, *release.ID, nil)
		platformStruct := xbmc.GetPlatform()
		platform := platformStruct.OS + "_" + platformStruct.Arch
		var assetAllPlatforms string
		for _, asset := range assets {
			if strings.HasSuffix(*asset.Name, platform+".zip") {
				assetPlatform := *asset.BrowserDownloadURL
				log.Info("Using release asset for " + platform + ": " + assetPlatform)
				ctx.Redirect(302, assetPlatform)
				return
			}
			if addonZipRE.MatchString(*asset.Name) {
				assetAllPlatforms = *asset.BrowserDownloadURL
				log.Info("Found all platforms release asset: " + assetAllPlatforms)
				continue
			}
		}
		if assetAllPlatforms != "" {
			log.Info("Using release asset for all platforms: " + assetAllPlatforms)
			ctx.Redirect(302, assetAllPlatforms)
			return
		}
	}
	ctx.AbortWithError(404, errors.New("Release asset not found."))
}
예제 #2
0
파일: config.go 프로젝트: felipejfc/quasar
func Reload() *Configuration {
	log.Info("Reloading configuration...")

	info := xbmc.GetAddonInfo()
	info.Path = xbmc.TranslatePath(info.Path)
	info.Profile = xbmc.TranslatePath(info.Profile)
	platform := xbmc.GetPlatform()

	if platform.OS == "android" {
		legacyPath := strings.Replace(info.Path, "/storage/emulated/0", "/storage/emulated/legacy", 1)
		if _, err := os.Stat(legacyPath); err == nil {
			info.Path = legacyPath
			info.Profile = strings.Replace(info.Profile, "/storage/emulated/0", "/storage/emulated/legacy", 1)
			log.Info("Using /storage/emulated/legacy path.")
		}
	}

	newConfig := Configuration{
		DownloadPath:        filepath.Dir(xbmc.GetSettingString("download_path")),
		LibraryPath:         filepath.Dir(xbmc.GetSettingString("library_path")),
		Info:                info,
		Platform:            platform,
		Language:            xbmc.GetLanguageISO_639_1(),
		ProfilePath:         info.Profile,
		BufferSize:          xbmc.GetSettingInt("buffer_size") * 1024 * 1024,
		UploadRateLimit:     xbmc.GetSettingInt("max_upload_rate") * 1024,
		DownloadRateLimit:   xbmc.GetSettingInt("max_download_rate") * 1024,
		LimitAfterBuffering: xbmc.GetSettingBool("limit_after_buffering"),
		BackgroundHandling:  xbmc.GetSettingBool("background_handling"),
		KeepFilesAfterStop:  xbmc.GetSettingBool("keep_files"),
		EnablePagination:    xbmc.GetSettingBool("enable_pagination"),
		EnableOverlayStatus: xbmc.GetSettingBool("enable_overlay_status"),
		ChooseStreamAuto:    xbmc.GetSettingBool("choose_stream_auto"),
		UseOriginalTitle:    xbmc.GetSettingBool("use_original_title"),
		PreReleaseUpdates:   xbmc.GetSettingBool("pre_release_updates"),
		BTListenPortMin:     xbmc.GetSettingInt("listen_port_min"),
		BTListenPortMax:     xbmc.GetSettingInt("listen_port_max"),
		ConnectionsLimit:    xbmc.GetSettingInt("connections_limit"),
		SessionSave:         xbmc.GetSettingInt("session_save"),
		TMDBApiKey:          xbmc.GetSettingString("tmdb_api_key"),

		CustomProviderTimeoutEnabled: xbmc.GetSettingBool("custom_provider_timeout_enabled"),
		CustomProviderTimeout:        xbmc.GetSettingInt("custom_provider_timeout"),

		SocksEnabled:  xbmc.GetSettingBool("socks_enabled"),
		SocksHost:     xbmc.GetSettingString("socks_host"),
		SocksPort:     xbmc.GetSettingInt("socks_port"),
		SocksLogin:    xbmc.GetSettingString("socks_login"),
		SocksPassword: xbmc.GetSettingString("socks_password"),
	}
	newConfig.TorrentsPath = filepath.Join(newConfig.DownloadPath, "Torrents")

	lock.Lock()
	config = &newConfig
	lock.Unlock()

	return config
}
예제 #3
0
파일: config.go 프로젝트: peer23peer/quasar
func Reload() *Configuration {
	log.Info("Reloading configuration...")

	info := xbmc.GetAddonInfo()
	info.Path = xbmc.TranslatePath(info.Path)
	info.Profile = xbmc.TranslatePath(info.Profile)

	info.Path = strings.Replace(info.Path, "/storage/emulated/0", "/storage/emulated/legacy", 1)
	info.Profile = strings.Replace(info.Profile, "/storage/emulated/0", "/storage/emulated/legacy", 1)

	newConfig := Configuration{
		DownloadPath:        filepath.Dir(xbmc.GetSettingString("download_path")),
		LibraryPath:         filepath.Dir(xbmc.GetSettingString("library_path")),
		Info:                info,
		Platform:            xbmc.GetPlatform(),
		Language:            xbmc.GetLanguageISO_639_1(),
		ProfilePath:         info.Profile,
		BufferSize:          xbmc.GetSettingInt("buffer_size") * 1024 * 1024,
		UploadRateLimit:     xbmc.GetSettingInt("max_upload_rate") * 1024,
		DownloadRateLimit:   xbmc.GetSettingInt("max_download_rate") * 1024,
		LimitAfterBuffering: xbmc.GetSettingBool("limit_after_buffering"),
		KeepFilesAfterStop:  xbmc.GetSettingBool("keep_files"),
		EnablePaging:        xbmc.GetSettingBool("enable_paging"),
		EnableOverlayStatus: xbmc.GetSettingBool("enable_overlay_status"),
		ChooseStreamAuto:    xbmc.GetSettingBool("choose_stream_auto"),
		PreReleaseUpdates:   xbmc.GetSettingBool("pre_release_updates"),
		BTListenPortMin:     xbmc.GetSettingInt("listen_port_min"),
		BTListenPortMax:     xbmc.GetSettingInt("listen_port_max"),

		CustomProviderTimeoutEnabled: xbmc.GetSettingBool("custom_provider_timeout_enabled"),
		CustomProviderTimeout:        xbmc.GetSettingInt("custom_provider_timeout"),

		SocksEnabled:  xbmc.GetSettingBool("socks_enabled"),
		SocksHost:     xbmc.GetSettingString("socks_host"),
		SocksPort:     xbmc.GetSettingInt("socks_port"),
		SocksLogin:    xbmc.GetSettingString("socks_login"),
		SocksPassword: xbmc.GetSettingString("socks_password"),
	}
	lock.Lock()
	config = &newConfig
	lock.Unlock()

	return config
}
예제 #4
0
파일: config.go 프로젝트: i96751414/quasar
func Reload() *Configuration {
	log.Info("Reloading configuration...")

	info := xbmc.GetAddonInfo()
	info.Path = xbmc.TranslatePath(info.Path)
	info.Profile = xbmc.TranslatePath(info.Profile)
	platform := xbmc.GetPlatform()

	if platform.OS == "android" {
		legacyPath := strings.Replace(info.Path, "/storage/emulated/0", "/storage/emulated/legacy", 1)
		if _, err := os.Stat(legacyPath); err == nil {
			info.Path = legacyPath
			info.Profile = strings.Replace(info.Profile, "/storage/emulated/0", "/storage/emulated/legacy", 1)
			log.Info("Using /storage/emulated/legacy path.")
		}
	}

	downloadPath := filepath.Dir(xbmc.GetSettingString("download_path"))
	if downloadPath == "." {
		xbmc.Notify("Quasar", "LOCALIZE[30113]", filepath.Join(info.Path, "icon.png"))
		xbmc.AddonSettings("plugin.video.quasar")
	}

	newConfig := Configuration{
		DownloadPath:        downloadPath,
		LibraryPath:         filepath.Dir(xbmc.GetSettingString("library_path")),
		TorrentsPath:        filepath.Join(downloadPath, "Torrents"),
		Info:                info,
		Platform:            platform,
		Language:            xbmc.GetLanguageISO_639_1(),
		ProfilePath:         info.Profile,
		BufferSize:          xbmc.GetSettingInt("buffer_size") * 1024 * 1024,
		UploadRateLimit:     xbmc.GetSettingInt("max_upload_rate") * 1024,
		DownloadRateLimit:   xbmc.GetSettingInt("max_download_rate") * 1024,
		LimitAfterBuffering: xbmc.GetSettingBool("limit_after_buffering"),
		BackgroundHandling:  xbmc.GetSettingBool("background_handling"),
		KeepFilesAfterStop:  xbmc.GetSettingBool("keep_files"),
		ResultsPerPage:      xbmc.GetSettingInt("results_per_page"),
		EnableOverlayStatus: xbmc.GetSettingBool("enable_overlay_status"),
		ChooseStreamAuto:    xbmc.GetSettingBool("choose_stream_auto"),
		UseOriginalTitle:    xbmc.GetSettingBool("use_original_title"),
		AddSpecials:         xbmc.GetSettingBool("add_specials"),
		PreReleaseUpdates:   xbmc.GetSettingBool("pre_release_updates"),
		ShareRatioLimit:     xbmc.GetSettingInt("share_ratio_limit"),
		SeedTimeRatioLimit:  xbmc.GetSettingInt("seed_time_ratio_limit"),
		SeedTimeLimit:       xbmc.GetSettingInt("seed_time_limit") * 3600,
		DisableDHT:          xbmc.GetSettingBool("disable_dht"),
		BTListenPortMin:     xbmc.GetSettingInt("listen_port_min"),
		BTListenPortMax:     xbmc.GetSettingInt("listen_port_max"),
		ConnectionsLimit:    xbmc.GetSettingInt("connections_limit"),
		SessionSave:         xbmc.GetSettingInt("session_save"),
		Scrobble:            xbmc.GetSettingBool("trakt_scrobble"),
		TraktUsername:       xbmc.GetSettingString("trakt_username"),
		TraktToken:          xbmc.GetSettingString("trakt_token"),
		TraktRefreshToken:   xbmc.GetSettingString("trakt_refresh_token"),
		CloudHoleKey:        xbmc.GetSettingString("cloudhole_key"),
		TMDBApiKey:          xbmc.GetSettingString("tmdb_api_key"),

		SortingModeMovies:           xbmc.GetSettingInt("sorting_mode_movies"),
		SortingModeShows:            xbmc.GetSettingInt("sorting_mode_shows"),
		ResolutionPreferenceMovies:  xbmc.GetSettingInt("resolution_preference_movies"),
		ResolutionPreferenceShows:   xbmc.GetSettingInt("resolution_preference_shows"),
		PercentageAdditionalSeeders: xbmc.GetSettingInt("percentage_additional_seeders"),

		CustomProviderTimeoutEnabled: xbmc.GetSettingBool("custom_provider_timeout_enabled"),
		CustomProviderTimeout:        xbmc.GetSettingInt("custom_provider_timeout"),

		SocksEnabled:  xbmc.GetSettingBool("socks_enabled"),
		SocksHost:     xbmc.GetSettingString("socks_host"),
		SocksPort:     xbmc.GetSettingInt("socks_port"),
		SocksLogin:    xbmc.GetSettingString("socks_login"),
		SocksPassword: xbmc.GetSettingString("socks_password"),
	}

	lock.Lock()
	config = &newConfig
	lock.Unlock()

	return config
}