Warning: this is an htmlized version!
The original is across this link,
and the conversion rules are here.
#######
#
# E-scripts on YouTube, youtube-dl, etc.
#
# Note 1: use the eev command (defined in eev.el) and the
# ee alias (in my .zshrc) to execute parts of this file.
# Executing this file as a whole makes no sense.
#
# Note 2: be VERY careful and make sure you understand what
# you're doing.
#
# Note 3: If you use a shell other than zsh things like |&
# and the for loops may not work.
#
# Note 4: I always run as root.
#
# Note 5: some parts are too old and don't work anymore. Some
# never worked.
#
# Note 6: the definitions for the find-xxxfile commands are on my
# .emacs.
#
# Note 7: if you see a strange command check my .zshrc -- it may
# be defined there as a function or an alias.
#
# Note 8: the sections without dates are always older than the
# sections with dates.
#
# This file is at <http://angg.twu.net/e/youtube.e>
#           or at <http://angg.twu.net/e/youtube.e.html>.
#        See also <http://angg.twu.net/emacs.html>,
#                 <http://angg.twu.net/.emacs[.html]>,
#                 <http://angg.twu.net/.zshrc[.html]>,
#                 <http://angg.twu.net/escripts.html>,
#             and <http://angg.twu.net/>.
#
#######





# «.debian»			(to "debian")
# «.restrict-filenames»		(to "restrict-filenames")
# «.youtube-dl-git»		(to "youtube-dl-git")
# «.irc-channel»		(to "irc-channel")
# «.update»			(to "update")
# «.youtube-dl-U»		(to "youtube-dl-U")
# «.upload-date»		(to "upload-date")
# «.splitting-file-names»	(to "splitting-file-names")
# «.thumbnails»			(to "thumbnails")
# «.video-formats»		(to "video-formats")
# «.youtube-title»		(to "youtube-title")
# «.username-and-password»	(to "username-and-password")
# «.subtitles»			(to "subtitles")
# «.bug-report»			(to "bug-report")
# «.extract-audio»		(to "extract-audio")
# «.youtube-dl-avconv-warning»	(to "youtube-dl-avconv-warning")


# (find-esgrep "grep -nH -e youtube-dl *.e")





#####
#
# Debian package
# 2013aug18
#
#####

# «debian» (to ".debian")
# (find-status   "youtube-dl")
# (find-vldifile "youtube-dl.list")
# (find-udfile   "youtube-dl/")
# (find-fline "/usr/share/pyshared/youtube_dl/extractor/")
# (find-fline "/usr/share/pyshared/youtube_dl/extractor/youtube.py")




#####
#
# -restrict-filenames
# 2013aug18
#
#####

# «restrict-filenames» (to ".restrict-filenames")
(code-c-d "ydl"  "/usr/share/pyshared/youtube_dl/")
(code-c-d "ydle" "/usr/share/pyshared/youtube_dl/extractor/")
;; (find-ydlfile "")
;; (find-ydlefile "")

# (find-ydlgrep "grep -nH -e restrict *")
# (find-ydlfile "__init__.py" "'--restrict-filenames'")
# (find-ydlgrep "grep -nrH -e restrictfilenames *")
# (find-ydlgrep "grep -nrH -e restricted *")
# (find-ydlgrep "grep -nrH -e sanitize *")

# (find-ydlfile "utils.py" "def sanitize_filename")



#####
#
# youtube-dl from git
# 2013aug18
#
#####

# «youtube-dl-git» (to ".youtube-dl-git")
# (find-angg ".emacs" "youtube-dl")
# http://rg3.github.io/youtube-dl/
# https://github.com/rg3/youtube-dl
# https://github.com/rg3/youtube-dl.git
# https://yt-dl.org/
# http://youtube-dl.org/
# http://rg3.github.io/youtube-dl/download.html

# (find-git-links "https://github.com/rg3/youtube-dl.git" "youtubedl")

(code-c-d "youtubedl"   "~/usrc/youtube-dl/")
(code-c-d "youtubedly"  "~/usrc/youtube-dl/youtube_dl/")
(code-c-d "youtubedlye" "~/usrc/youtube-dl/youtube_dl/extractor/")
;; (find-youtubedlfile "")
;; (find-youtubedlyfile "")
;; (find-youtubedlyefile "")

# (find-sh "youtube-dl")
# (find-sh "youtube-dl -h")
# (find-freenode-links "#youtube-dl")

# From now on, get the binaries from
# http://rg3.github.io/youtube-dl/download.html, not from the git
# repository.

# (find-youtubedlgrep "grep --color -nrH -e update *")
# (find-youtubedlyfile "options.py" "'-U', '--update'")






#####
#
# IRC channel
# 2013aug18
#
#####

# «irc-channel» (to ".irc-channel")
# (find-freenode "#youtube-dl")
# (find-freenode-3a "#youtube-dl")
# (find-fline "~/LOGS/2013aug18.youtube-dl")



#####
#
# update
# 2013oct11
#
#####

# «update» (to ".update")
# «youtube-dl-U» (to ".youtube-dl-U")
# (find-youtubedlgrep "grep -nirH -e update *")
# (find-youtubedlfile "README.md" "-U, --update")
# (find-youtubedlyfile "__init__.py" "'--update'")
# (find-youtubedlyfile "update.py")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
youtube-dl -U

# (find-sh "locate youtube-dl")
# (find-fline "/usr/bin/youtube-dl")
# (find-fline "/usr/local/bin/youtube-dl")




#####
#
# upload date
# 2014apr21
#
#####

# «upload-date» (to ".upload-date")
# (find-youtubedlfile "README.md" "upload_date")
# (find-youtubedlfile "README.md" "-e, --get-title")
# (find-youtubedlfile "README.md" "--get-format")
# (find-youtubedlfile "README.md" "--get-filename")
# (find-youtubedlfile "README.md" "-o, --output TEMPLATE" "%(upload_date)s")
# (find-youtubedlfile "README.md" "The current default template is")
# (find-anggfile "LUA/youtube-db.lua" "yt ()" "youtube-dl -e")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
youtube-dl --get-format "http://www.youtube.com/watch?v=g5quWjBJMwc"
youtube-dl --get-title "http://www.youtube.com/watch?v=g5quWjBJMwc"
youtube-dl --get-description "http://www.youtube.com/watch?v=g5quWjBJMwc"
youtube-dl --get-filename "http://www.youtube.com/watch?v=g5quWjBJMwc"
youtube-dl --get-filename -o "%(upload_date)s" "http://www.youtube.com/watch?v=g5quWjBJMwc"



#####
#
# Splitting the file name of a video downloaded by youtube-dl
# 2013aug18
#
#####

# «splitting-file-names» (to ".splitting-file-names")
# (find-eevgrep "grep -nH -e tubedl *.el")
# (find-eevgrep "grep -nH -e termpl *.el")
# (find-eev "eev-tlinks.el" "find-youtubedl-links")
# (find-angg ".emacs.templates" "find-youtubedl-links")

(setq re "\\(\\.[A-Za-z0-9]\\{2,5\\}\\)\\{0,2\\}$")
(setq str "foo.bar.plic.ploc.mp4")
(setq str "foo.bar.plich.plocaboo.mp4")
(setq str "plocaboo")
(and (string-match re str) (list (substring str 0 (match-beginning 0)) (match-string 0 str)))

(substring "abcdefgh" 0 1)
(substring "abcdefgh" 0 -2)
(substring "abcdefgh" -4 0)


 (match-string 0 fname))




#####
#
# thumbnails
# 2013sep14
#
#####

# «thumbnails» (to ".thumbnails")

# (find-man "youtube-dl")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
~/usrc/youtube-dl/youtube-dl --write-thumbnail 'http://www.youtube.com/watch?v=Rx-L8hxrJlg'

cd /tmp/
# Bad char:
# youtube-dl --write-thumbnail 'http://www.youtube.com/watch?v=1_7HV_Vq2CE'




#####
#
# video formats
# 2013sep14
#
#####

# «video-formats» (to ".video-formats")
# (find-es "android" "video-formats")

Available formats:
35	:	flv	[480x854]
44	:	webm	[480x854]
34	:	flv	[360x640]
18	:	mp4	[360x640]
43	:	webm	[360x640]
5	:	flv	[240x400]
17	:	mp4	[144x176]




#####
#
# youtube-title
# 2013nov24
#
#####

# «youtube-title» (to ".youtube-title")
# (find-angg ".emacs" "youtube-title")
# (find-es "charsets" "recode")
# (find-sh "recode -l" "HTML")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
youtube-dl -e 'http://www.youtube.com/watch?v=TqoUp0_4aMY'
youtube-dl -e 'http://www.youtube.com/watch?v=TqoUp0_4aMY' | recode h..l1




#####
#
# user and password
# 2014apr23
#
#####

# «username-and-password» (to ".username-and-password")
# (find-sh "youtube-dl" "-u, --username")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
youtube-dl -u foo@gmail.com -p sikrit \
  'https://www.facebook.com/photo.php?v=658872984184130'




#####
#
# subtitles
# 2014jun05
#
#####

# «subtitles» (to ".subtitles")
# (find-sh "youtube-dl -h" "Subtitle Options:")




#####
#
# Bug report: non-ascii chars in -e
# 2014aug06
#
#####

# «bug-report» (to ".bug-report")
# https://github.com/rg3/youtube-dl/issues
# https://github.com/rg3/youtube-dl/issues/3460
# Non-ascii chars in "-e", and a project that uses youtube-dl #3460




#####
#
# extract-audio
# 2015feb15
#
#####

# «extract-audio» (to ".extract-audio")
# http://www.gluglug.org.uk/tutorials/accessing-youtube/#comment-101
# (find-sh "youtube-dl")
# (find-sh "youtube-dl -h")
# (find-sh "youtube-dl -h" "-x, --extract-audio")
# (find-sh "youtube-dl -h" "--audio-format FORMAT")
# (find-sh "youtube-dl -h" "--restrict-filenames")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
youtube-dl -x --audio-format mp3 "http://www.youtube.com/watch?v=YVXftEvBipI"
youtube-dl -x --audio-format mp3 --restrict-filenames \
  "http://www.youtube.com/watch?v=DbyzmiXnB7o"


# 2015feb14:
# http://www.gluglug.org.uk/tutorials/accessing-youtube/#comment-304




#####
#
# WARNING: Your copy of avconv is outdated and unable to properly mux...
# 2016jan05
#
#####

# «youtube-dl-avconv-warning» (to ".youtube-dl-avconv-warning")
# WARNING: Your copy of avconv is outdated and unable to properly mux
# separate video and audio files, youtube-dl will download single file
# media. Update avconv to version 10-0 or newer to fix this.

# https://github.com/rg3/youtube-dl/issues/4451
# http://askubuntu.com/questions/563245/avconv-warning-while-downloading-youtube-video
https://askubuntu.com/questions/563245/avconv-warning-while-downloading-youtube-video








cd /tmp/
youtube-dl -v -v -v \
  --write-info-json \
  -e "http://www.youtube.com/watch?v=n72B3zCOLU0" \
  |& tee /tmp/o


# write_youtube_date_into("Pap4N7G2rPM", "/tmp/ydb/Pap4N7G2rPM.date")
# write_youtube_title_into("Pap4N7G2rPM", "/tmp/ydb/Pap4N7G2rPM.title")
# download_youtube_mp4("Pap4N7G2rPM", "/tmp/ydb/videos/")

# (find-sh "youtube-dl -h")
# (find-fline "~/LOGS/2014aug06.youtube-dl")









#  Local Variables:
#  modes: (fundamental-mode emacs-lisp-mode)
#  coding:               raw-text-unix
#  ee-delimiter-hash:    "\n#*\n"
#  ee-delimiter-percent: "\n%*\n"
#  ee-anchor-format:     "«%s»"
#  End: