// downloadCastFile downloads the cast file and
// returns castFilePath, castFileName
downloadCastFile downloads the cast file and
returns castFilePath, castFileName
// downloadCastFile downloads the cast file and // returns castFilePath castFileName
func downloadCastFile(castUrl string, outputDir string) (string, string) {
	fileUrl := castUrl + ".cast"
	h := sha1.New()
	h.Write([]byte(castUrl))
	castUrlHash := fmt.Sprintf("%x", h.Sum(nil))
	castFileName := castUrlHash + ".cast"
	castFilePath := filepath.Join(outputDir, castFileName)
	if _, err := os.Stat(castFilePath); os.IsNotExist(err) {
	} else {
		return castFilePath, castFileName
	}
	resp, err := http.Get(fileUrl)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	castFile, err := os.Create(castFilePath)
	if err != nil {
		panic(err)
	}
	_, err = io.Copy(castFile, resp.Body)
	castFile.Close()
	return castFilePath, castFileName
}
func downloadCastFile ( castUrl string , outputDir string ) ( string , string ) { fileUrl := castUrl + " " h := sha1 . New ( ) h . Write ( [ ] byte ( castUrl ) ) castUrlHash := fmt . Sprintf ( " " , h . Sum ( nil ) ) castFileName := castUrlHash + " " castFilePath := filepath . Join ( outputDir , castFileName ) if _ , err := os . Stat ( castFilePath ) ; os . IsNotExist ( err ) { } else { return castFilePath , castFileName } resp , err := http . Get ( fileUrl ) if err != nil { panic ( err ) } defer resp . Body . Close ( ) castFile , err := os . Create ( castFilePath ) if err != nil { panic ( err ) } _ , err = io . Copy ( castFile , resp . Body ) castFile . Close ( ) return castFilePath , castFileName }
downloadCastFile downloads the cast file and
returns castFilePath, castFileName
downloadCastFile downloads the cast file and returns castFilePath castFileName
// TODO parse URLs variations // Create hash for caching // Set cast file vars // Check file already exist // and return if exist // castFilePath does not exist // Download Cast file // Create cast file to temp file // Write cast file to temp file