#!/bin/sh
#] 
#] *********************
#] $ bash "$d_bin""wget download.sh"  - example download [file, site, directory]s
# www.BillHowell.ca  29Jan2021 initial 
# must remove leaddizeros for the paper#, eg "0081" ->  "81"  


#************************

source  "$d_bin""standard header.sh"

# see "$d_bin""Standard header.sh"
# 	date_ymdhm=$(date +"%y%m%d %kh%Mm")
# 	becho - echo to [screen, logfile]
# 	beval - echo command to [screen, logfile] then eval it
#		for extreme examples of beval : 
#		$ find  "/home/bill/PROJECTS/bin/"  -maxdepth 1  -type f  -name "*.sh"  |   tr  \\n  \\0  |  xargs -0  -IFILE  grep  --with-filename  --line-number  "beval" "FILE"  
#				backup computer [to,from] TravelUSB.sh:29
#				encrypt-open.sh:34

# 25Oct2023 don't use option -O?
# -O file
# output-document=file

# The documents will not be written to the appropriate files, but all will be concatenated together and written to file.  If - is used as file, documents will be printed to standard output, disabling link conversion.  (Use ./- to print to a file literally named -.)

# Use of -O is not intended to mean simply "use the name file instead of the one in the URL;" rather, it is analogous to shell redirection: wget -O file http://foo is intended to work like wget -O -http://foo > file; file will be truncated immediately, and all downloaded content will be written there.

# For this reason, -N (for timestamp-checking) is not supported in combination with -O: since file is always newly created, it will always have a very new timestamp. A warning will be issued if this combination is used.

# Similarly, using -r or -p with -O may not work as you expect: Wget won't just download the first file to file and then download the rest to their normal names: all downloaded content will be placed in file. This was disabled in version 1.11, but has been reinstated (with a warning) in 1.11.2, as there are some cases where this behavior can actually have some use.

# A combination with -nc is only accepted if the given output file does not exist.

# Note that a combination with -k is only permitted when downloading a single document, as in that case it will just convert all relative URIs to external ones; -k makes no sense for multiple URIs when they're all being downloaded to a single file; -k can be used only when the output is a regular file.

# usually don't use revursive - images in same dir
#	-r --recursive		Turn on recursive retrieving. The default maximum depth is 5.


#************
#] code 


#] URL_wget_dirList()  - download directory of webSite (example) : doesn't work so use lftp
# 22Feb2024 doesn't work so use lftp, - no --list-only for LMDE

	URL_wget_dirList()
{  
	d_OnLin="http://www.BillHowell.ca/Bill Howells videos/"

	pDirLst="$d_temp"'URL_wget_dirList -r Bill Howells videos.txt' 
	wget --list-only -r  "$d_OnLin"  "$pDirLst"

	pDirLst="$d_temp"'URL_wget_dirList    Bill Howells videos.txt' 
	wget --list-only     "$d_OnLin"  "$pDirLst"

}



#] Fusion_energy_conf_16Sep2020()  - example of conference downloads

	Fusion_energy_conf_16Sep2020()
{  
	date_ymdhms=$(date +"%0y%0m%0d %0kh%0Mm%0Ss")
	echo  >>"$p_log" "$date_ymdhms chown_Howell"

	d_down="$d_SWAPPER"'My_Clubs/Fusion alliance Alberta/200817 Fusion Energy Council Cda (FECC) mtg 16Sep2020/'
	
	wget -O  "$d_down""Whyte of MIT 16Dec2020 Recent Progress on the High-Field Path to Fusion Energy.pptx"  "http://firefusionpower.org/FPA20_SPARC_Whyte_.pptx"  
	wget -O  "$d_down""Wade of ORNL Fusion Energy Program 16Dec2020 Accomplishments and opportunities for the 2020s.pptx"	 "http://firefusionpower.org/FPA20_Wade_ORNL.pptx"  
	wget -O  "$d_down""McLean of LLNL 16Dec2020 Fusion Energy Sciences Program at LLNL Fusion Energy Sciences Program at LLNL.pdf"	 "http://firefusionpower.org/FPA20_McLean_LLNL-PRES-817811.pdf"  
	wget -O  "$d_down""Nelson of Zap Energy 16Dc2020 Sheared-Flow Stabilized (SFS) Z-Pinch Reactor Concept.pdf"	 "http://firefusionpower.org/FPA20_SFS_Nelson_ZapEnergy.pdf"  
	wget -O  "$d_down""Schenkel of LBNL 16Dec2020 Fusion Energy Sciences at LBNL.pdf"	 "http://firefusionpower.org/FPA20_Schenkel_LBNL.pdf"  
	wget -O  "$d_down""Lessons Learned from 40 Years of Fusion Science and Technology.pptx"	 "http://firefusionpower.org/FPA20_Abdou_FSTC_UCLA.pptx"  
	wget -O  "$d_down""Kline of LANL 16Dec2020 Fusion Power Program at LANL.pdf"	 "http://firefusionpower.org/FPA20_Kline_LANL_Fusion_Res.pdf"  
	wget -O  "$d_down""Waelbroeck of U Texas 16Dec2020 Fusion Energy Research at UT.pdf"	 "http://firefusionpower.org/FPA20_Waelbroeck_IFS_Univ_TX.pdf"  
	wget -O  "$d_down""Babineau of SRNL 16Dec2020 Tritium Science and Technology for Fusion Energy Success.pdf"	 "http://firefusionpower.org/FPA20_Babineau_Tritium_SRNL.pdf"  
	wget -O  "$d_down""Greenfield of UBPO-GA The US Burning Plasma Organization.pdf"	 "http://firefusionpower.org/FPA_USBPO_Greenfield_GA.pdf"  
	wget -O  "$d_down""Zuegel of U. Rochester 16Dc2020 Fourth-generation Laser for Ultrabroadband eXperiments (FLUX) for mitigation of LPI & beam imprint with bandwidth.pptx"	 "http://firefusionpower.org/FPA20_Zuegel_LLE_Rochester.pptx"  
	wget -O  "$d_down""Clark of USDOE 16Dec2020 Innovation Network for Fusion Energy (INFUSE) Program Overview.pptx"	 "http://firefusionpower.org/FPA20_Clark_INFUSE.pptx"  
}  


#] yahoo_puts()  - download files, doesn't work - yahoo browser output is not a file (perhaps another approach?)

yahoo_puts()
{	
	date_ymdhms=$(date +"%0y%0m%0d %0kh%0Mm%0Ss")
	echo  >>"$p_log" "$date_ymdhms yahoo_puts"

	d_down="/media/bill/Dell2/Website - raw/economics, markets/options/TSLA/"  
	f_down="$date_ymdhm ""Tesla puts.txt"
	wget -O  "$d_down$f_down"  "https://finance.yahoo.com/quote/TSLA/options?date=1620950400&guce_referrer=aHR0cHM6Ly9kdWNrZHVja2dvLmNvbS8&guce_referrer_sig=AQAAAL3RicF8gsDW9h1guVk-aJxkVXalzAdgs0e6CHG6LYr9UwECtRKbiwhBNx8RbzEo32_k5yWH4l71tygrgpjnRRA-EdH5QGsWWqpWvNnkN5ZZcfX_3W_IWNeqQVUrfRQop6GQB0bLHXKM4iLOaNdqDVQwEQk_8QuhCaWll4LFfQkv&straddle=false"  

}  


#] IJCNN2021_wget_vid()  - download presentations
# see $ bash "$d_bin""IJCNN2021 wget download.sh"  - download IJCNN2021 videos

IJCNN2021_wget_vid()
{	
	date_ymdhms=$(date +"%0y%0m%0d %0kh%0Mm%0Ss")
	echo  >>"$p_log" "$date_ymdhms IJCNN2021_wget_vid"

	d_get="https://confcats-event-sessions.s3.amazonaws.com/ijcnn21/videos/"
	d_down="/media/bill/Dell2/PROJECTS/2021 IJCNN Shenzen, China/vidDwnLoad temp/"  
	wget -O  "$d_down$2.mp4"  "$d_get$1.mp4"  
}  



#************
# run - select one of options



#	Fusion_energy_conf_16Sep2020
#	yahoo_puts

	URL_wget_dirList





# $ bash "$d_bin""wget download.sh" 

# enddoc
