Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
-- This file:
-- http://angg.twu.net/youtube-db/scripts.lua
-- http://angg.twu.net/youtube-db/scripts.lua.html
--  (find-angg        "youtube-db/scripts.lua")
-- 2014aug01
--
-- «.pack-tgz»			(to "pack-tgz")
-- «.demo-readme»		(to "demo-readme")
-- «.demo-simple2»		(to "demo-simple2")
-- «.demo-YScripts»		(to "demo-YScripts")
-- «.demo-simple»		(to "demo-simple")
-- «.demo-enith»		(to "demo-enith")
--
-- «.2016jun10»			(to "2016jun10")
-- «.update-youtube-dl»		(to "update-youtube-dl")
-- «.2014jul26»			(to "2014jul26")
-- «.test-simple»		(to "test-simple")
-- «.cp-and-download»		(to "cp-and-download")
-- «.get-new-titles»		(to "get-new-titles")
-- «.get-new-dates»		(to "get-new-dates")
-- «.dump-tags»			(to "dump-tags")
-- «.dates»			(to "dates")
-- «.line_to_hash»		(to "line_to_hash")


dofile "ydbtoolbox.lua"
dofile "db.lua"
dofile "dbu.lua"

-- (find-fline "~/blogme3/cruft-jan2024.lua")
ee_dofile "~/blogme3/cruft-jan2024.lua"










--[[

#                   _    
#  _ __   __ _  ___| | __
# | '_ \ / _` |/ __| |/ /
# | |_) | (_| | (__|   < 
# | .__/ \__,_|\___|_|\_\
# |_|                    
#
# «pack-tgz» (to ".pack-tgz")
# (yg)
* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
rm -v ~/youtube-db/ydb.tgz
cd    ~/youtube-db/
git archive -o ydb.tgz HEAD
ls -lAF ydb*.tgz

# (find-ydbsh "tar -tvzf ydb.tgz")

DATE=$(date +%Y%m%d)
cp -v   ydb.tgz ydb-$DATE.tgz
ls -lAF ydb*.tgz

cd ~/youtube-db/
Scp -v ydb-$DATE.tgz ydb.tgz \
  edrx@angg.twu.net:/home/edrx/slow_html/youtube-db/
Scp -v ydb-$DATE.tgz ydb.tgz \
  edrx@angg.twu.net:/home/edrx/public_html/youtube-db/

# (find-ydbsh "tar -tvzf ydb.tgz")




#      _                                               _                
#   __| | ___ _ __ ___   ___        _ __ ___  __ _  __| |_ __ ___   ___ 
#  / _` |/ _ \ '_ ` _ \ / _ \ _____| '__/ _ \/ _` |/ _` | '_ ` _ \ / _ \
# | (_| |  __/ | | | | | (_) |_____| | |  __/ (_| | (_| | | | | | |  __/
#  \__,_|\___|_| |_| |_|\___/      |_|  \___|\__,_|\__,_|_| |_| |_|\___|
#                                                                       
# See: (find-ydbfile "README" "Downloading, installing, testing")
# This is exactly the code from the README - but with a trick: my
# upstream-ish version is kept at ~/youtube-db/, and the README
# recommends unpacking at ~/ydb/, so we delete ~/ydb/ for the test and
# recreate it with the contents of the .tgz to check that all the
# required files are present.

-- «demo-readme» (to ".demo-readme")
* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# (find-ydb "")
# (find-ydb "README")

# Make ydb.tgz
cd ~/youtube-db/
rm -v ydb.tgz
git archive -o ydb.tgz HEAD

tar -tvzf ydb.tgz

rm -Rv ~/ydb/
mkdir  ~/ydb/
cd     ~/ydb/
cp -v ~/youtube-db/ydb.tgz .
# wget http://angg.twu.net/youtube-db/ydb.tgz
tar -xvzf ydb.tgz

export LUA_INIT=

cp -v ~/ydb/test1.txt /tmp/
cd /tmp/
~/ydb/ydb -fake -simple test1
. test1.sh
~/ydb/ydb -fake -simple test1
mv test1.txt2 test1.txt
~/ydb/ydb -fake -simple test1
  
# file:///tmp/test1.html

rm -v  /tmp/test1.*
rm -Rv /tmp/videos/
rm -Rv /tmp/ydbtmp/

cp -v ~/ydb/test1.txt /tmp/
cd /tmp/
~/ydb/ydb -simple test1
. test1.sh
~/ydb/ydb -simple test1
mv test1.txt2 test1.txt
~/ydb/ydb -simple test1

# file:///tmp/test1.html





-- «demo-simple2» (to ".demo-simple2")
* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
rm -Rv /tmp/ydb/
rm -Rv /tmp/videos/
mkdir  /tmp/videos/
cp -v ~/youtube-db/test1.txt .
# (find-ydbfile    "test1.txt")
# (find-fline "/tmp/test1.txt")

# (find-ydb "ydbtoolbox.lua" "YScripts")
# (find-ydb "ydbtoolbox.lua" "simple_toplevel2")
# (find-ydb "ydb" "simple2")

* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "ydb"
youtubedbdir = "/home/edrx/youtube-db/"
dofile "scripts.lua"
chdir "/tmp/"

ys = YScripts.fake()
-- simple_toplevel2(ys, "test1")
dooptions("-fake", "-simple2", "/tmp/test1")

Full test:


* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
rm -Rv /tmp/ydb/
rm -Rv /tmp/videos/
mkdir  /tmp/videos/
cp -v  ~/youtube-db/test1.txt /tmp/
# (find-fline "/tmp/test1.txt")

cd /tmp/
ydb -fake -simple2 /tmp/test1
. test1.sh
# (find-fline "/tmp/test1.sh")
ydb -fake -simple2 /tmp/test1
# (find-fline "/tmp/" "test1")
cp -v test1.txt2 test1.txt
ydb -fake -simple2 /tmp/test1




# (find-fline "/tmp/")



-- «demo-YScripts» (to ".demo-YScripts")
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "scripts.lua"

= YScripts.new():dl_mp4(split("a b c"))
= YScripts{}:dl_mp4(split("a b c"))
= YScripts{}:dl_mp4(split("a b c d e f g"))
= YScripts{}:dl_date(split("a b c d e f g"))
= YScripts{}:dl_title(split("a b c d e f g"))
= YScripts.fake():dl_title(split("a b c d e f g"))
= YScripts.real():dl_title(split("a b c d e f g"))
= YScripts.fake():dl_title(split("a b c d e f g h i j k l"))
= YScripts.real():dl_title(split("a b c d e f g h i j k l"))
= YScripts.real():dl_title(split("a b c d e f g h i j k"))
= YScripts.real():dl_title(split("a b c d e f g h i j"))



* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
for i in $(seq 1 20); do
~/youtube-db/ydb -local 'http://www.youtube.com/watch?v=Ikd0ZYQoDko'
done

-- «demo-simple» (to ".demo-simple")
* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
rm -Rv /tmp/ydb/
rm -Rv /tmp/videos/
mkdir  /tmp/videos/
cp -v ~/youtube-db/test1.txt .
# (find-ydbfile    "test1.txt")
# (find-fline "/tmp/test1.txt")

cd /tmp/
~/youtube-db/ydb -simple /tmp/test1

# (find-ydbfile "ydbtoolbox.lua" "write_script_gd =")

# (find-fline "/tmp/test1.dl")
# (find-fline "/tmp/test1.gd")
# (find-fline "/tmp/test1.gt")
# (find-fline "/tmp/test1.lst")
. /tmp/test1.dl
. /tmp/test1.gd
. /tmp/test1.gt
# (find-fline "/tmp/videos/")
# (find-fline "/tmp/ydb/")
tkdiff /tmp/test1.txt /tmp/test1.txt2
cp -v /tmp/test1.txt2 /tmp/test1.txt
# file:///tmp/test1.html





-- «demo-enith» (to ".demo-enith")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
rm -Rv /tmp/ydb/
rm -Rv /tmp/videos/
mkdir  /tmp/videos/
# (find-ydbfile    "enith.txt")
# (find-fline "/tmp/enith.txt")

cd /tmp/
~/youtube-db/ydb -simple /tmp/enith
# (find-fline "/tmp/enith.dl")
# (find-fline "/tmp/enith.gd")
# (find-fline "/tmp/enith.gt")
# (find-fline "/tmp/enith.lst")
. /tmp/enith.dl
. /tmp/enith.gd
. /tmp/enith.gt
# (find-fline "/tmp/videos/")
# (find-fline "/tmp/ydb/")
tkdiff /tmp/enith.txt /tmp/enith.txt2
cp -v /tmp/enith.txt2 /tmp/enith.txt
# file:///tmp/enith.html





* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "ydb"
=           ee_readfile "/tmp/test.txt"
= no_coding(ee_readfile "/tmp/test.txt")

* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
* (find-sh0 "cp -v ~/linkdasruas.txt /tmp/test.txt")
dofile "scripts.lua"
Txt = YoutubeDB.new():read("~/linkdasruas2.txt")
Org = YoutubeDB.new():read("~/linkdasruas3.org")
= Txt
= Org
= Txt - Org
(Txt - Org):dump_all()
= Org - Txt
 
 y:ls("/sda5/videos/")


--]]





--[[
-- «2016jun10» (to ".2016jun10")
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "scripts.lua"
dofile "ydb"
-- (find-ydb "ydb" "big_db_angg")
Bigdb = big_db_angg():hash_valid()

-- Get missing titles
  Titleless = Bigdb:title_no()
= Titleless
= Titleless:titles_script()
= Titleless:titles_script("$EE").." (Now run ee on a shell)"

* (eepitch-shell2)
# (find-es "youtube" "standard-installation")
ee
jobs
* (eepitch-lua51)

Titleless:titles_cat()
= Titleless:title_no()
= Titleless:dump_all()




-- «update-youtube-dl»  (to ".update-youtube-dl")
-- See: (find-es "youtube" "yt-dlp")
--
* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
apti  youtube-dl
aptrm youtube-dl
apti python3-pip

pip3 install --upgrade yt-dlp

pip3 install youtube-dl
youtube-dl -U

pip3 uninstall -y youtube-dl
pip3   install    youtube-dl



-- «2014jul26» (to ".2014jul26")
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "scripts.lua"
dofile "ydb"
-- (find-ydb "ydb" "big_db_angg")
Bigdb = big_db_angg():hash_valid()
Mp4s  = ls_db_angg()               -- (find-ydb "ydb" "ls_db_angg")
Txt   = lr_db_angg()               -- (find-ydb "ydb" "lr_db_angg")

ys.cpdir = "~/TH/L/manifs/"
Mini = YoutubeDB.new():ls(ys.cpdir)
Tocopy = (Mp4s * Txt) - Mini
= Tocopy
= (Bigdb * Tocopy):dump_all()
= Tocopy:cp_script()

-- Create linkdasruas2.lst
chdir "~/TH/L/"
ys.cpdir = "manifs/"
Mini = YoutubeDB.new():ls(ys.cpdir)
(Mini * Txt):write_lst("~/linkdasruas2.lst")
-- (find-fline "~/linkdasruas2.lst")
-- Remake linkdasruas2.html
-- (find-zsh "cd; touch ~/TH/linkdasruas2.blogme; makeL")

-- Get missing titles
  Titleless = Bigdb:title_no()
= Titleless
= Titleless:titles_script()
= Titleless:titles_script("$EE").." (Now run ee on a shell)"
  Titleless:titles_cat()
= Titleless:title_no()
= Titleless:dump_all()

-- Get missing dates
  Dateless = (Bigdb * Txt):date_no():err_no()
= Dateless
= Dateless:dump_all()
= Dateless:dates_script()
= Dateless:dates_cat()
= Dateless:date_no()
= Dateless:dump_all()

-- Which videos to add to linkdasruas
= (Bigdb - Txt):tags_eq("p")
= (Bigdb - Txt):tags_eq("p"):dump_all()

-- (Bigdb):tag_yes("ind"):dump_all()

-- Download missing videos
ys.mp4dir = "/sda7/videos/manifs"

Mp4less = Txt:tag_no("no"):tag_no("err"):tag_no("longo"):tag_no("int") - Mp4s
= Mp4less
= Mp4less:dump_all()
= Mp4less:mp4s_script()

-- = Mp4less:write_script_dl("/tmp/o.dl", "/sda7/videos/manifs/")
-- (find-fline "/tmp/o.dl")


-- Generate linkdasruas2.txt2 and compare it with the original
-- The "del_tag"s are destructive, so this must be done last
--
Bigdb:del_tag("p")
Bigdb:del_tag("dl")
Bigdb:del_tag("i")
Bigdb:write_new_txt("~/linkdasruas2.txt", "~/linkdasruas2.txt2")
Bigdb:write_new_txt("~/linkdasruas3.org", "~/linkdasruas3.org2")
-- (find-fline      "~/linkdasruas2.txt")
-- (find-fline      "~/linkdasruas3.org")
-- (find-tkdiff     "~/linkdasruas2.txt"  "~/linkdasruas2.txt2")
-- (find-tkdiff     "~/linkdasruas3.org"  "~/linkdasruas3.org2")
-- (find-sh0 "cp -v  ~/linkdasruas2.txt2   ~/linkdasruas2.txt")
-- (find-sh0 "cp -v  ~/linkdasruas3.org2   ~/linkdasruas3.org")
-- Remake linkdasruas2.html
-- (find-zsh "cd; touch ~/TH/linkdasruas2.blogme; makeL")





--
(Bigdb:tags_eq("p") - Mp4s):dump_all()
= Bigdb:tags_eq("p") - Mp4s
= Bigdb:tags_eq("p")
  Bigdb:tags_eq("p"):dump_all()
  Bigdb:tags_eq("p"):dump_all()

= Txt










= to_dl:write_script_dl("/tmp/o.dl", "/sda7/videos/manifs/")
-- (find-fline "/tmp/o.dl")

-- Copy new videos to ~/TH/L/manifs/
chdir "~/TH/L/"
thdb = YoutubeDB.new():ls("manifs/")
lrfiles1 = Mp4s * Txt
lrfiles2 = thdb * Txt
= lrfiles1
= lrfiles2
= lrfiles1 - lrfiles2
= (Bigdb * (lrfiles1 - lrfiles2)):dump_all()
= (lrfiles1 - lrfiles2):write_script_cp("/tmp/o.cp", "~/TH/L/manifs/")
-- (find-fline "/tmp/o.cp")
-- (find-sh  ". /tmp/o.cp")

-- Generate linkdasruas2.lst
chdir "~/TH/L/"
thdb = YoutubeDB.new():ls("manifs/")
(thdb * Txt):write_lst("~/linkdasruas2.lst")

-- Remake linkdasruas2.html
-- (find-zsh "cd; touch ~/TH/linkdasruas2.blogme; makeL")











-- «test-simple» (to ".test-simple")
-- (find-ydb "toolbox.lua" "write_html_dynamic")
-- (to "simple_toplevel")

-- (find-fline "/tmp/")
-- (find-fline "/tmp/ydb/")
-- (find-fline "/tmp/test.dl")
-- (find-fline "/tmp/test.gd")
-- (find-fline "/tmp/test.gt")

-- (find-tkdiff "/tmp/test.txt" "/tmp/test.txt2")
-- (find-sh "cp -v /tmp/test.txt2 /tmp/test.txt")





* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "scripts.lua"
Db = YoutubeDB.new():register_videos(youtube_db_string)
Db = YoutubeDB.new():read0(youtube_db_string)
= Db:copy_dates_into(linkdasruas_txt0)


* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "scripts.lua"
= YoutubeDB.new():read("~/linkdasruas.txt")
= YoutubeDB.new():read("~/linkdasruas2.txt")




-- «get-new-titles» (to ".get-new-titles")
-- «get-new-dates» (to ".get-new-dates")
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "scripts.lua"

y = YoutubeDB.new()
= y:read("~/linkdasruas2.txt", "manifs")
= y:register_videos(youtube_db_string)
= y:run("grep youtu ~/TODO")
= y:run("grep youtu ~/varda/TODO")
= y:run("grep youtu ~/ORG/index.org")
= y:run("grep youtu ~/varda/index.org")
= y:ls("/sda5/videos/")
= y:ls("/sda7/videos/")

PP(y:has("y7E5Vy0PinY"))


= y:new_titles_script()
= y:new_titles_dump()

= y:tag_yes("manifs"):date_yes()
= y:tag_yes("manifs"):date_no()
= y:tag_yes("manifs"):date_no():err_no()
= y:tag_yes("manifs"):date_no():err_no():dump_all()

= y:tag_yes("manifs"):err_no():new_dates_script()
= y:tag_yes("manifs"):err_no():new_dates_dump()

y:dump_tags()
= y:hash_valid()
y:hash_valid():dump_by_tags {"p"}
y:hash_valid():tags_eq("p"):dump_all()
= y:hash_valid():tags_eq("p"):new_dates_script()
= y:hash_valid():tags_eq("p"):new_dates_dump()

= y:copy_dates_into(ee_readfile "~/linkdasruas2.txt")
-- (find-fline "~/linkdasruas2.txt")





= y:tag_yes("manifs"):new_dates_script()
= y:tag_yes("manifs"):new_dates_dump()







= y:title_no()


= y:script_yt()
= y:hash_valid():script_yt()
= y:new_titles()

= #y.hashes_list
= y.hashes_list[6846]
PP(y.hashes[y.hashes_list[6846] ])
PP(y.hashes["fUanwRF69H8"])

y:title_no():hash_valid():dump_all()

= y:filter(L "h,e -> e.tags.err")
  y:filter(L "h,e -> e.tags.err"):dump_all()

y:dump_by_tags {""}







-- «test»








-- «cp-and-download» (to ".cp-and-download")

* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "scripts.lua"

chdir "~/TH/L/"
Lr      = YoutubeDB.new():read("~/linkdasruas2.txt")
Vf_all  = YoutubeDB.new():ls ("/sda5/videos/manifs/")
                   Vf_all:ls ("/sda7/videos/manifs/")
Vf_mini = YoutubeDB.new():ls ("manifs/")
Err     = YoutubeDB.new():register_videos(youtube_db_string):err_yes()

To_lst      =  Lr          * Vf_mini
To_copy     =  Lr * Vf_all - Vf_mini
To_download =  Lr - Vf_all
To_download = (Lr - Vf_all):err_no()
To_download = (Lr - Vf_all):err_no():tag_no("longo")
To_download = (Lr - Vf_all - Err):err_no():tag_no("longo")
To_download = (Lr - Vf_all - Err):err_no():tag_no("longo"):tag_no("i")

script_cp   =  Vf_all:script_cp_angg(To_copy:h())
script_dl   =      Lr:script_dl_angg(To_download:h())
script_lst  = Vf_mini:video_fnames_list(To_lst:h())

ee_writefile("/tmp/o_cp", script_cp)          -- (find-fline "/tmp/o_cp")
ee_writefile("/tmp/o_dl", script_dl)          -- (find-fline "/tmp/o_dl")
ee_writefile("~/linkdasruas2.lst", script_lst) -- (find-angg "linkdasruas2.lst")

To_download:dump_all()
To_download:tag_no("i"):dump_all()
To_download:tag_yes("i"):dump_all()

= Lr
= Vf_all
= Vf_mini
= To_copy
= To_download
= Err

** (find-sh  ". /tmp/o_cp")
** (eev (ee-read-file "/tmp/o_dl"))
** (find-zsh "cd; touch ~/TH/linkdasruas2.blogme; makeL1 linkdasruas2.html")
** (find-zsh "cd; touch ~/TH/linkdasruas2.blogme; makeL")

** To delete all current symlinks: (find-sh "rm -v ~/TH/L/manifs/*.mp4")




-- «dump-tags» (to ".dump-tags")
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "scripts.lua"

Db = YoutubeDB.new()
= Db:register_videos(youtube_db_string)
= Db:register_videos_read("~/linkdasruas2.txt", "manifs")
= Db:register_videos_read("~/linkdasruas2.txt")
= Db:register_videos_run("grep youtu ~/TODO")
= Db:register_videos_run("grep youtu ~/varda/TODO")
= Db:register_videos_run("grep youtu ~/ORG/index.org")
= Db:register_videos_run("grep youtu ~/varda/index.org")

chdir "~/TH/L/"
Lr      = YoutubeDB.new():register_videos_read("~/linkdasruas2.txt")
Vf_all  = YoutubeDB.new():register_video_fnames_ls("/sda5/videos/manifs/")
Vf_mini = YoutubeDB.new():register_video_fnames_ls("manifs/")

Db:dump_tags()
Db:dump_by_tags {"longo,p"}
Db:dump_by_tags {"i,p"}
Db:dump_by_tags {"ed,p"}
Db:dump_by_tags {"p"}
Db:dump_by_tags {"t"}
Db:dump_by_tags {"p,te"}
Db:dump_by_tags {"u"}
Db:dump_by_tags {""}
Db:dump_by_tags {"xe"}
Db:dump_by_tags {"a"}

dump_all()

= Db:date_yes()
  Db:date_yes():dump_all()





tags_eq

tag_yes
tag_no



-- «dates» (to ".dates")

* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "scripts.lua"

Db = YoutubeDB.new()
= Db:register_videos(youtube_db_string)
= Db:register_videos_read("~/linkdasruas.txt", "manifs")
= Db:register_videos_run("grep youtu ~/TODO")
= Db:register_videos_run("grep youtu ~/varda/TODO")
= Db:register_videos_run("grep youtu ~/ORG/index.org")
= Db:register_videos_run("grep youtu ~/varda/index.org")

= Db:tag_yes("manifs"):date_yes()
= Db:tag_yes("manifs"):date_no()

= Db:filter(L "h,e -> e.tags.manifs"):date_yes()
= Db:filter(L "h,e -> e.tags.manifs"):date_no()


Db:filter(L "h,e -> e.tags.manifs"):date_no():dump_all()



mystr = [===[
[xe] http://www.youtube.com/watch?v=tY1-L2wyrvA Co e Ocupa Garden (RN)
[xe] 20001234 20001256 http://www.youtube.com/watch?v=eP1h0JItNVI Anarko 13
[xe] http://www.youtube.com/watch?v=oQIpZRY8RaU As Noivas | Maio | 2012
]===]
Db = YoutubeDB.new()
Db:register_videos(mystr)
Db:dump_all()

Db:dump_by_tags {"xe"}
Db:add_date("eP1h0JItNVI", "20001234")
Db:add_date("eP1h0JItNVI", "20001256")
Db:dump_by_tags {"xe"}    -- buggy: wrong display of dates
= Db:date_yes()
  Db:date_yes():dump_all()



Db = YoutubeDB.new()
= Db:register_videos(youtube_db_string)
= Db:register_videos(youtube_dbu_string)
= Db:register_videos_read("~/linkdasruas.txt", "manifs")
= Db:register_videos_run("grep youtu ~/TODO")

= Db:date_yes()
  Db:date_yes():dump_all()





for a,b,c,d,e,f in gen_tag_hash_title(mystr) do
  PP(a,b,c,d,e,f)
end








= Db:register_videos_run("grep youtu ~/varda/TODO")
= Db:register_videos_run("grep youtu ~/ORG/index.org")
= Db:register_videos_run("grep youtu ~/varda/index.org")



= Db:hash_to_line "eP1h0JItNVI"

PP(Db.hashes["eP1h0JItNVI"])

PP(sort_uniq {"aa", "bb", "aa"})


do
local h = "eP1h0JItNVI"
local e  = Db.hashes[h]
local ed = Db.hashes[h].dates
local d = "20001234"; ed[d]=d
local d = "20001256"; ed[d]=d
PP(e)
end

= Db:adates("eP1h0JItNVI")

Db:dump_by_tags {"xe"}
= Db:date_yes()
= Db:date_yes():dump_all()
= Db:title_yes()
= Db:title_no()
= Db:title_no():hash_valid():dump_all()

PP(pre_to_tag_and_dates("[xe] 20001234 20001256 http://www.you"))
PP(pre_to_tag_and_dates("[xe] http://www.you"))
PP(pre_to_tag_and_dates("[xe] abcd http://www.you"))
PP(pre_to_tag_and_dates("[xe] [foo] abcd http://www.you"))
PP(pre_to_tag_and_dates("  abcd http://www.you"))

-- (find-ydb "toolbox.lua" "bigstrs")
-- (find-ydb "toolbox.lua" "bigstrs" "gen_tag_hash_title")
-- (find-ydb "toolbox.lua" "dates")
-- (find-ydb "toolbox.lua" "dates" "pre_to_tag_and_dates")





word = "[aa,bb]"
PP(word:match "^%[(.*)%]$" or "cc")

local t = 

li = "[xe] 20001234 20001256 http://www.youtube.com/watch?v=eP1h0JItNVI Anako 13"
PP(pre_to_tag_and_dates(li))




 {"xe"}


YoutubeDB.__index.
    adates = function (ydb, hash)
        print "hi"
        PP(ydb.hashes[hash].dates)
        PP(Set.from(keys(ydb.hashes[hash].dates)):ks())
        local ds = Set.from(keys(ydb.hashes[hash].dates)):ks()
        return mapconcat(function (d) return d.." " end, ds)
      end



chdir "~/TH/L/"
Lr      = YoutubeDB.new():register_videos_read("~/linkdasruas.txt")
Vf_all  = YoutubeDB.new():register_video_fnames_ls("/sda5/videos/manifs/")
Vf_mini = YoutubeDB.new():register_video_fnames_ls("manifs/")

Db:dump_tags()
Db:dump_by_tags {"longo,p"}
Db:dump_by_tags {"i,p"}
Db:dump_by_tags {"ed,p"}
Db:dump_by_tags {"p"}
Db:dump_by_tags {"t"}
Db:dump_by_tags {"p,te"}
Db:dump_by_tags {"u"}
Db:dump_by_tags {""}
Db:dump_by_tags {"xe"}
Db:dump_by_tags {"a"}

dump_all()













do
  local fname = ee_expand("$EE").."1"
  local script = y:script_yt()
  writefile(fname, script)
  print(fname, #script.." bytes")
end

# (find-fline "/home/edrx/.eev/ee.sh1")

# (find-fline "/tmp/yt/")
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)

hash  = "HepcwnB19C0"
fname = "/tmp/yt/"..hash..".t"
fname2 = "/tmp/yt/foo"
contents = readfile(fname)

do
  local lines = {}
  local Hs = y:hashes_without_titles()
  for _,hash in ipairs(Hs) do
    local fname = "/tmp/yt/"..hash..".t"
    local ok,contents = pcall(function () return readfile(fname) end)
    if ok then table.insert(lines, youtube_make_url(hash).." "..contents) end
  end
  print(table.concat(lines))
end




= y:script_yt()
= y:hashes_without_titles_yt()



-- Old:



-- Print items with multiple titles
for hash,tags,titles in gen_hash_tags_titles() do
  if #titles > 1 then
    print(hash.." "..titles[1])
    for i=2,#titles do
      print("            "..titles[i])
    end
  end
end


-- print(tag,hash,title)
-- (fooi-re "#a?t=[0-9ms]+" "")
-- (fooi-re "&list=[!-~]+" "")
-- (fooi-re "&desktop_uri=[!-~]+" "")
-- (fooi "m.youtube.com" "www.youtube.com")
-- (find-blogme3 "youtube.lua")
--]]




-- (find-fline "~/linkdasruas.txt")
-- (find-ydbfile "db.lua" "y7E5Vy0PinY")
linkdasruas_txt = ee_readfile("~/linkdasruas2.txt")
linkdasruas_txt0 = [[
7 de setembro
 http://www.youtube.com/watch?v=y7E5Vy0PinY 7 de setembro
 http://www.youtube.com/watch?v=WOHFJDTO2VE Gás lacrimogênio dentro do metro RJ Centro ***
 7/set/2013 http://www.youtube.com/watch?v=2plMRXtqCHc Bombas de gás lacrimogênio dentro do metro ! RJ - Centro ***
 7/set/2013 http://www.youtube.com/watch?v=TqoUp0_4aMY Fechando o Metrô ***

[p] http://www.youtube.com/watch?v=zBg3pYrG1G8 Venha para o Rio de Janeiro nas Olimpíadas 2016 (Come to Rio 2016 Olympics)
[p] http://www.youtube.com/watch?v=VgLVM7CNa70 Porquê Lula é uma Farsa.
[p] http://www.youtube.com/watch?v=vad4IMYo_aQ Massacre de Corumbiara - parte 1
[p] http://www.youtube.com/watch?v=358zX6OcB2k Jean Wyllys fecha com Marcelo Freixo
]]




-- (find-blogme3 "blogme3.lua")
-- (find-blogme3 "options.lua")

-- PP(YoutubeDB.new():ls0(ee_readfile "~/linkdasruas2.lst"))

-- «line_to_hash» (to ".line_to_hash")


-- (find-fline "~/linkdasruas2.lst")
-- (find-sh "lua51 scripts.lua -local")
-- (find-sh "lua51 scripts.lua -local nsPihryfwvk")
-- (find-sh "lua51 scripts.lua -local 'http://www.youtube.com/watch?v=6p63miupDx8'")
-- (find-sh "lua51 scripts.lua -simple ~/TH/L/manifs/ /tmp/test")


-- Local Variables:
-- coding: raw-text-unix
-- End: