[youtube]
This commit is contained in:
		
							parent
							
								
									ba5a22efc3
								
							
						
					
					
						commit
						c3c394742d
					
				
					 1 changed files with 20 additions and 0 deletions
				
			
		
							
								
								
									
										20
									
								
								.config/scriptrc/youtube.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								.config/scriptrc/youtube.sh
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,20 @@
 | 
				
			||||||
 | 
					read_arg_paste_read() {
 | 
				
			||||||
 | 
					  local x=$1
 | 
				
			||||||
 | 
					  [ -z "$x" ] && x=$(pbpaste)
 | 
				
			||||||
 | 
					  [[ $x != http* ]] && read x
 | 
				
			||||||
 | 
					  echo "$x"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					youtube_download() {
 | 
				
			||||||
 | 
					  torsocks yt-dlp "$1" --cookies-from-browser safari -t $3 -o $2
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					youtube_watch() {
 | 
				
			||||||
 | 
					  local url=$(read_arg_paste_read "$1")
 | 
				
			||||||
 | 
					  local tempfname=$(gmktemp --suffix=.mp4)
 | 
				
			||||||
 | 
					  rm $tempfname
 | 
				
			||||||
 | 
					  echo "Downloading $url to $tempfname"
 | 
				
			||||||
 | 
					  youtube_download "$url" "$tempfname" mp4
 | 
				
			||||||
 | 
					  open -W $tempfname
 | 
				
			||||||
 | 
					  rm $tempfname
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in a new issue