Scraper Lite
# Mix.install([
# {:poison, "~> 5.0"},
# {:floki, "~> 0.35.2"},
# {:req, "~> 0.4.8"},
# {:youtube_captions, "~> 0.1.0"}
# ])
Root
# defmodule R do
# def recompile() do
# Mix.Task.reenable("app.start")
# Mix.Task.reenable("compile")
# Mix.Task.reenable("compile.all")
# compilers = Mix.compilers()
# Enum.each(compilers, &Mix.Task.reenable("compile.#{&1}"))
# Mix.Task.run("compile.all")
# end
# end
# R.recompile()
# {:ok, src} = Vyasa.Written.create_source(%{title: "rama"})
# Vyasa.Medium.Writer.init(%)
ADMIN TASKS
Vyasa.Written.get_chapters_by_src("hanuman_chalisa")
|> hd()
|> Map.get(:translations)
|> hd()
|> Vyasa.Written.Translation.changeset(%{"type" => "chapters", "target" => %{
"title" => "Hanuman Chalisa",
"title_translit" => "Hanuman Chalisa",
"body" =>"The Hanuman Chalisa, composed by Goswami Tulsidas, is a 40-verse hymn dedicated to Lord Hanuman, highlighting his unwavering devotion to Lord Rama. It is a testament to Hanuman's strength, wisdom, and courage, as well as his role in Lord Rama's epic battles against evil. Reciting this hymn is believed to bestow blessings and protection from Hanuman, fostering spiritual growth and devotion to Lord Rama.",
}})
|> Vyasa.Repo.update!()
VEL
verse = """
0. திருத்தணியில் உதித்(து)அருளும் ஒருத்தன்மலை
விருத்தன்என(து) உளத்தில்உறை
கருத்தன்மயில் நடத்துகுகன் வேலே
[இந்த அடியை முதலில் 12 முறை ஓதவும்]
1. பருத்தமுலை சிறுத்தஇடை வெளுத்தநகை
கறுத்தகுழல் சிவத்தஇதழ் மறச்சிறுமி
விழிக்குநிகர் ஆகும் (திரு)
2. திருத்தணியில் உதித்(து)அருளும் ஒருத்தன்மலை
விருத்தன்என(து) உளத்தில்உறை
கருத்தன்மயில் நடத்துகுகன் வேலே (திரு)
3. சொலற்(கு)அரிய திருப்புகழை உரைத்தவரை
அடுத்தபகை அறுத்(து)எறிய
உறுக்கிஎழும் அறத்தைநிலை காணும் (திரு)
4. தருக்கிநமன் முருக்கவரின் எருக்குமதி
தரித்தமுடி படைத்தவிறல் படைத்தஇறை
கழற்குநிகர் ஆகும் (திரு)
5. பனைக்கைமுக படக்கரட மதத்தவள
கஜக்கடவுள் பதத்(து)இடு(ம்)நி
களத்துமுளை தெறிக்கவரம் ஆகும் (திரு)
6. சினத்(து)அவுணர் எதிர்த்தரண களத்தில்வெகு
குறைத்தலைகள் சிரித்(து)எயிறு
கடித்துவிழி விழித்(து)அலற மோதும் (திரு)
7. துதிக்கும்அடி யவர்க்(கு)ஒருவர் கெடுக்கஇடர்
நினைக்கின்அவர் குலத்தைமுதல் அறக்களையும்
எனக்(கு)ஓர் துணை ஆகும் (திரு)
8. தலத்தில்உள கணத்தொகுதி களிப்பின்உண
வழைப்ப(து) என மலர்க்கமல கரத்தின்முனை
விதிர்க்கவளை(வு) ஆகும் (திரு)
9. பழுத்தமுது தமிழ்ப்பலகை இருக்கும்ஒரு
கவிப்புலவன் இசைக்(கு)உருகி
வரைக்குகையை இடித்துவழி காணும் (திரு)
10. திசைக்கிரியை முதற்குலிசன் அறுத்தசிறை
முளைத்த(து)என முகட்டின்இடை
பறக்கஅற விசைத்(து) அதிர ஓடும் (திரு)
11. சுடர்ப்பரிதி ஒளிப்பநில(வு) ஒழுக்கு(ம்)மதி
ஒளிப்பஅலை அடக்குதழல் ஒளிப்பஒளிர்
ஒளிப்பிரபை வீசும் (திரு)
12. தனித்துவழி நடக்கும்என(து) இடத்தும்ஒரு
வலத்தும்இரு புறத்தும்அரு(கு)
அடுத்(து)இரவு பகற்றுணைய(து) ஆகும் (திரு)
13. பசித்(து)அலகை முசித்(து)அழுது முறைப்படுதல்
ஒழித்(து)அவுணர் உரத்(து)உதிர
நிணத்தசைகள் புசிக்கஅருள் நேரும் (திரு)
14. திரைக்கடலை உடைத்துநிறை புனற்கடிது
குடித்(து)உடையும் உடைப்(பு) அடைய
அடைத்(து)உதிரம் நிறைத்துவிளை யாடும் (திரு)
15. சுரர்க்கு(ம்)முநி வரர்க்கு(ம்)மக பதிக்கும்விதி
தனக்கும்அரி தனக்கும்நரர் தமக்கும்உறும்
இடுக்கண்வினை சாடும் (திரு)
16. சலத்துவரும் அரக்கர்உடல் கொழுத்துவளர்
பெருத்தகுடர் சிவத்ததொடை
எனச்சிகையில் விருப்பமொடு சூடும் (திரு)
17. சுரர்க்கு(ம்)முநி வரர்க்கு(ம்)மக பதிக்கும்விதி
தனக்கும்அரி தனக்கும்நரர் தமக்கும்உறும்
இடுக்கண்வினை சாடும் (திரு)
18. சலத்துவரும் அரக்கர்உடல் கொழுத்துவளர்
பெருத்தகுடர் சிவத்ததொடை
எனச்சிகையில் விருப்பமொடு சூடும் (திரு)
19. பசித்(து)அலகை முசித்(து)அழுது முறைப்படுதல்
ஒழித்(து)அவுணர் உரத்(து)உதிர
நிணத்தசைகள் புசிக்கஅருள் நேரும் (திரு)
20. திரைக்கடலை உடைத்துநிறை புனற்கடிது
குடித்(து)உடையும் உடைப்(பு) அடைய
அடைத்(து)உதிரம் நிறைத்துவிளை யாடும் (திரு)
21. சுடர்ப்பரிதி ஒளிப்பநில(வு) ஒழுக்கு(ம்)மதி
ஒளிப்பஅலை அடக்குதழல் ஒளிப்பஒளிர்
ஒளிப்பிரபை வீசும் (திரு)
22. தனித்துவழி நடக்கும்என(து) இடத்தும்ஒரு
வலத்தும்இரு புறத்தும்அரு(கு)
அடுத்(து)இரவு பகற்றுணைய(து) ஆகும் (திரு)
23. பழுத்தமுது தமிழ்ப்பலகை இருக்கும்ஒரு
கவிப்புலவன் இசைக்(கு)உருகி
வரைக்குகையை இடித்துவழி காணும் (திரு)
24. திசைக்கிரியை முதற்குலிசன் அறுத்தசிறை
முளைத்த(து)என முகட்டின்இடை
பறக்கஅற விசைத்(து) அதிர ஓடும் (திரு)
25. துதிக்கும்அடி யவர்க்(கு)ஒருவர் கெடுக்கஇடர்
நினைக்கின்அவர் குலத்தைமுதல் அறக்களையும்
எனக்(கு)ஓர் துணை ஆகும் (திரு)
26. தலத்தில்உள கணத்தொகுதி களிப்பின்உண
வழைப்ப(து) என மலர்க்கமல கரத்தின்முனை
விதிர்க்கவளை(வு) ஆகும் (திரு)
27. பனைக்கைமுக படக்கரட மதத்தவள
கஜக்கடவுள் பதத்(து)இடு(ம்)நி
களத்துமுளை தெறிக்கவரம் ஆகும் (திரு)
28. சினத்(து)அவுணர் எதிர்த்தரண களத்தில்வெகு
குறைத்தலைகள் சிரித்(து)எயிறு
கடித்துவிழி விழித்(து)அலற மோதும் (திரு)
29. சொலற்(கு)அரிய திருப்புகழை உரைத்தவரை
அடுத்தபகை அறுத்(து)எறிய
உறுக்கிஎழும் அறத்தைநிலை காணும் (திரு)
30. தருக்கிநமன் முருக்கவரின் எருக்குமதி
தரித்தமுடி படைத்தவிறல் படைத்தஇறை
கழற்குநிகர் ஆகும் (திரு)
31. பருத்தமுலை சிறுத்தஇடை வெளுத்தநகை
கறுத்தகுழல் சிவத்தஇதழ் மறச்சிறுமி
விழிக்குநிகர் ஆகும் (திரு)
32. திருத்தணியில் உதித்(து)அருளும் ஒருத்தன்மலை
விருத்தன்என(து) உளத்தில்உறை
கருத்தன்மயில் நடத்துகுகன் வேலே (திரு)
33. தருக்கிநமன் முருக்கவரின் எருக்குமதி
தரித்தமுடி படைத்தவிறல் படைத்தஇறை
கழற்குநிகர் ஆகும் (திரு)
34. சொலற்(கு)அரிய திருப்புகழை உரைத்தவரை
அடுத்தபகை அறுத்(து)எறிய
உறுக்கிஎழும் அறத்தைநிலை காணும் (திரு)
35. திருத்தணியில் உதித்(து)அருளும் ஒருத்தன்மலை
விருத்தன்என(து) உளத்தில்உறை
கருத்தன்மயில் நடத்துகுகன் வேலே (திரு)
36. பருத்தமுலை சிறுத்தஇடை வெளுத்தநகை
கறுத்தகுழல் சிவத்தஇதழ் மறச்சிறுமி
விழிக்குநிகர் ஆகும் (திரு)
37. தலத்தில்உள கணத்தொகுதி களிப்பின்உண
வழைப்ப(து) என மலர்க்கமல கரத்தின்முனை
விதிர்க்கவளை(வு) ஆகும் (திரு)
38. துதிக்கும்அடி யவர்க்(கு)ஒருவர் கெடுக்கஇடர்
நினைக்கின்அவர் குலத்தைமுதல் அறக்களையும்
எனக்(கு)ஓர் துணை ஆகும் (திரு)
39. சினத்(து)அவுணர் எதிர்த்தரண களத்தில்வெகு
குறைத்தலைகள் சிரித்(து)எயிறு
கடித்துவிழி விழித்(து)அலற மோதும் (திரு)
40. பனைக்கைமுக படக்கரட மதத்தவள
கஜக்கடவுள் பதத்(து)இடு(ம்)நி
களத்துமுளை தெறிக்கவரம் ஆகும் (திரு)
41. தனித்துவழி நடக்கும்என(து) இடத்தும்ஒரு
வலத்தும்இரு புறத்தும்அரு(கு)
அடுத்(து)இரவு பகற்றுணைய(து) ஆகும் (திரு)
42. சுடர்ப்பரிதி ஒளிப்பநில(வு) ஒழுக்கு(ம்)மதி
ஒளிப்பஅலை அடக்குதழல் ஒளிப்பஒளிர்
ஒளிப்பிரபை வீசும் (திரு)
43. திசைக்கிரியை முதற்குலிசன் அறுத்தசிறை
முளைத்த(து)என முகட்டின்இடை
பறக்கஅற விசைத்(து) அதிர ஓடும் (திரு)
44. பழுத்தமுது தமிழ்ப்பலகை இருக்கும்ஒரு
கவிப்புலவன் இசைக்(கு)உருகி
வரைக்குகையை இடித்துவழி காணும் (திரு)
45. சலத்துவரும் அரக்கர்உடல் கொழுத்துவளர்
பெருத்தகுடர் சிவத்ததொடை
எனச்சிகையில் விருப்பமொடு சூடும் (திரு)
46. சுரர்க்கு(ம்)முநி வரர்க்கு(ம்)மக பதிக்கும்விதி
தனக்கும்அரி தனக்கும்நரர் தமக்கும்உறும்
இடுக்கண்வினை சாடும் (திரு)
47. திரைக்கடலை உடைத்துநிறை புனற்கடிது
குடித்(து)உடையும் உடைப்(பு) அடைய
அடைத்(து)உதிரம் நிறைத்துவிளை யாடும் (திரு)
48. பசித்(து)அலகை முசித்(து)அழுது முறைப்படுதல்
ஒழித்(து)அவுணர் உரத்(து)உதிர
நிணத்தசைகள் புசிக்கஅருள் நேரும் (திரு)
49. திரைக்கடலை உடைத்துநிறை புனற்கடிது
குடித்(து)உடையும் உடைப்(பு) அடைய
அடைத்(து)உதிரம் நிறைத்துவிளை யாடும் (திரு)
50. பசித்(து)அலகை முசித்(து)அழுது முறைப்படுதல்
ஒழித்(து)அவுணர் உரத்(து)உதிர
நிணத்தசைகள் புசிக்கஅருள் நேரும் (திரு)
51. சலத்துவரும் அரக்கர்உடல் கொழுத்துவளர்
பெருத்தகுடர் சிவத்ததொடை
எனச்சிகையில் விருப்பமொடு சூடும் (திரு)
52. சுரர்க்கு(ம்)முநி வரர்க்கு(ம்)மக பதிக்கும்விதி
தனக்கும்அரி தனக்கும்நரர் தமக்கும்உறும்
இடுக்கண்வினை சாடும் (திரு)
53. திசைக்கிரியை முதற்குலிசன் அறுத்தசிறை
முளைத்த(து)என முகட்டின்இடை
பறக்கஅற விசைத்(து) அதிர ஓடும் (திரு)
54. பழுத்தமுது தமிழ்ப்பலகை இருக்கும்ஒரு
கவிப்புலவன் இசைக்(கு)உருகி
வரைக்குகையை இடித்துவழி காணும் (திரு)
55. தனித்துவழி நடக்கும்என(து) இடத்தும்ஒரு
வலத்தும்இரு புறத்தும்அரு(கு)
அடுத்(து)இரவு பகற்றுணைய(து) ஆகும் (திரு)
56. சுடர்ப்பரிதி ஒளிப்பநில(வு) ஒழுக்கு(ம்)மதி
ஒளிப்பஅலை அடக்குதழல் ஒளிப்பஒளிர்
ஒளிப்பிரபை வீசும் (திரு)
57. சினத்(து)அவுணர் எதிர்த்தரண களத்தில்வெகு
குறைத்தலைகள் சிரித்(து)எயிறு
கடித்துவிழி விழித்(து)அலற மோதும் (திரு)
58. பனைக்கைமுக படக்கரட மதத்தவள
கஜக்கடவுள் பதத்(து)இடு(ம்)நி
களத்துமுளை தெறிக்கவரம் ஆகும் (திரு)
59. தலத்தில்உள கணத்தொகுதி களிப்பின்உண
வழைப்ப(து) என மலர்க்கமல கரத்தின்முனை
விதிர்க்கவளை(வு) ஆகும் (திரு)
60. துதிக்கும்அடி யவர்க்(கு)ஒருவர் கெடுக்கஇடர்
நினைக்கின்அவர் குலத்தைமுதல் அறக்களையும்
எனக்(கு)ஓர் துணை ஆகும் (திரு)
61. திருத்தணியில் உதித்(து)அருளும் ஒருத்தன்மலை
விருத்தன்என(து) உளத்தில்உறை
கருத்தன்மயில் நடத்துகுகன் வேலே (திரு)
62. பருத்தமுலை சிறுத்தஇடை வெளுத்தநகை
கறுத்தகுழல் சிவத்தஇதழ் மறச்சிறுமி
விழிக்குநிகர் ஆகும் (திரு)
63. தருக்கிநமன் முருக்கவரின் எருக்குமதி
தரித்தமுடி படைத்தவிறல் படைத்தஇறை
கழற்குநிகர் ஆகும் (திரு)
64. சொலற்(கு)அரிய திருப்புகழை உரைத்தவரை
அடுத்தபகை அறுத்(து)எறிய
உறுக்கிஎழும் அறத்தைநிலை காணும் (திரு)
65. திருத்தணியில் உதித்(து)அருளும் ஒருத்தன்மலை
விருத்தன்என(து) உளத்தில்உறை
கருத்தன்மயில் நடத்துகுகன் வேலே
[முடிவிலும் இந்த அடியை 12 முறை ஓதவும்]
"""
|> String.split("
")
|> Enum.map(fn << no::binary-size(4), verse::binary >> ->
{no |> String.trim() # Remove leading/trailing whitespace
|> String.replace(".", "") # Remove periods
|> String.to_integer(), (verse |> String.trim())}
end)
|> Enum.into(%{})
%{id: sid} =
source =
%Vyasa.Written.Source{}
|> Vyasa.Written.Source.gen_changeset(%{title: "vel_maaral", lang: "ta"})
|> Vyasa.Repo.insert!()
translit =
"""
0. Thiruthaniyil Uthithu arulum Oruthan Malai
Virudthan Enathu Ullathil Urai
Karuthan Mayil Nadaththu Guhan Velae
[This verse is to be recited 12 times at the start]
1. Paruthamulai Sirutha Idai Veluththanagai
Karuthakulal Sivaththa Ithazh Marasirumi
Vizhikku Nigar Aagum (Thiru)
2. Thiruthaniyil Uthithu Arulum Oruthan Malai
Viruththan Enathu Ullathil Urai
Karuthan Mayil Nadaththu Guhan Velae (Thiru)
3. Sollarkku ariya Thirupugazhai Uraithavarai
aduthapagai aruththu eriya
Urukki Ezhum araththai nilai Kaanum (Thiru)
4. Tharukkinaman Murukkavarin Erukkumathi
Tharithamudi Padaiththa Viral Padaiththa Irai
Kazharku Nigar Aagum (Thiru)
5. Panaikaimuga Padakarada Mathathavala
Gajakadavul Pathathu Idum Ni-
Kalathumulai Therikavaram Aagum (Thiru)
6. Sinathu avuNar Ethirtharana Kalathil Vegu
Kuraithalaigal Siruthu eyiru
Kadithu Vizhi Vizhiththu alara Mothum (Thiru)
7. Thuthikum adiyavaruku Oruvar Keduka Idar
Ninaikin avar Kulathai Muthal
arakkalaiyum Enaku Oore Thunai Aagum (Thiru)
8. Thalaththiluhla ganaththoguthi KalhippinuNa
Vazhaippathuena Malarkamala Karaththinmunai
Vithirka valhaivu Aagum (Thiru)
9. Pazhuthamuthu Thamizhppalagai irukkum Oru
Kavipulavan Isaikku Urugi
Varaiguhaiyai idiththu Vazhi Kaanum (Thiru)
10. Thisaikkiriyai Mutharrkulisan aruthasirai
Mulaithathu ena Mugattin Idai
Parakka ara Visaiththu athira Oodum (Thiru)
11. Sudarpparithi Olippa Nilavu Ozhukkum Mathi
Olippa alai adakkuthazhl Olippa Olir
Olip prabai Veesum (Thiru)
12. Thanithuvazhi Nadakkum Enathu idaththum Oru
Valatthum iru Purathum Arugu
Aduthu iravu Pagal thunayathu Aagum (Thiru)
13. Pasithu alagai Musithu azhuthu Muraippaduthal
Ozhithu avuNar Urathu Uthira
NiNaththasaigal Pusika arul Nerum (Thiru)
14. Thiraikkadalai Udaithunerai Punarkkadithu
Kudithu Udaiyum Udaippu adaiya
adaithu Uthiram Niraithu Vilaiyadum (Thiru)
15. Surarkkum Munivararkkum Magapathikumm Vithi
thanukumm ari thanakumm narar thamakumm Urum
idukkaN Vinai sAdum (Thiru)
16. Salathuvarum Arakar Udal Kozhuthu Valar
Peruthakudar Sivathathodai
Enasegaiyil Viruppamodu sUdum (Thiru)
17. Surarkkum Munivararkkum Magapathikumm Vithi
thanukumm ari thanakumm narar thamakumm Urum
idukkaN Vinai sAdum (Thiru)
18. Salathuvarum Arakar Udal Kozhuthu Valar
Peruthakudar Sivathathodai
Enasegaiyil Viruppamodu sUdum (Thiru)
19. Pasithu alagai Musithu azhuthu Muraippaduthal
Ozhithu avuNar Urathu Uthira
NiNaththasaigal Pusika arul Nerum (Thiru)
20. Thiraikkadalai Udaithunerai Punarkkadithu
Kudithu Udaiyum Udaippu adaiya
adaithu Uthiram Niraithu Vilaiyadum (Thiru)
21. Sudarpparithi Olippa Nilavu Ozhukkum Mathi
Olippa alai adakkuthazhl Olippa Olir
Olip prabai Veesum (Thiru)
22. Thanithuvazhi Nadakkum Enathu idaththum Oru
Valatthum iru Purathum Arugu
Aduthu iravu Pagal thunayathu Aagum (Thiru)
23. Pazhuthamuthu Thamizhppalagai irukkum Oru
Kavipulavan Isaikku Urugi
Varaiguhaiyai idiththu Vazhi Kaanum (Thiru)
24. Thisaikkiriyai Mutharrkulisan aruthasirai
Mulaithathu ena Mugattin Idai
Parakka ara Visaiththu athira Oodum (Thiru)
25. Thuthikum adiyavaruku Oruvar Keduka Idar
Ninaikin avar Kulathai Muthal
arakkalaiyum Enaku Oore Thunai Aagum (Thiru)
26. Thalaththiluhla ganaththoguthi KalhippinuNa
Vazhaippathuena Malarkamala Karaththinmunai
Vithirka valhaivu Aagum (Thiru)
27. Panaikaimuga Padakarada Mathathavala
Gajakadavul Pathathu Idum Ni-
Kalathumulai Therikavaram Aagum (Thiru)
28. Sinathu avuNar Ethirtharana Kalathil Vegu
Kuraithalaigal Siruthu eyiru
Kadithu Vizhi Vizhiththu alara Mothum (Thiru)
29. Sollarkku ariya Thirupugazhai Uraithavarai
aduthapagai aruththu eriya
Urukki Ezhum araththai nilai Kaanum (Thiru)
30. Tharukkinaman Murukkavarin Erukkumathi
Tharithamudi Padaiththa Viral Padaiththa Irai
Kazharku Nigar Aagum (Thiru)
31. Paruthamulai Sirutha Idai Veluththanagai
Karuthakulal Sivaththa Ithazh Marasirumi
Vizhikku Nigar Aagum (Thiru)
32. Thiruthaniyil Uthithu Arulum Oruthan Malai
Viruththan Enathu Ullathil Urai
Karuthan Mayil Nadaththu Guhan Velae (Thiru)
33. Tharukkinaman Murukkavarin Erukkumathi
Tharithamudi Padaiththa Viral Padaiththa Irai
Kazharku Nigar Aagum (Thiru)
34. Sollarkku ariya Thirupugazhai Uraithavarai
aduthapagai aruththu eriya
Urukki Ezhum araththai nilai Kaanum (Thiru)
35. Thiruthaniyil Uthithu Arulum Oruthan Malai
Viruththan Enathu Ullathil Urai
Karuthan Mayil Nadaththu Guhan Velae (Thiru)
36. Paruthamulai Sirutha Idai Veluththanagai
Karuthakulal Sivaththa Ithazh Marasirumi
Vizhikku Nigar Aagum (Thiru)
37. Thalaththiluhla ganaththoguthi KalhippinuNa
Vazhaippathuena Malarkamala Karaththinmunai
Vithirka valhaivu Aagum (Thiru)
38. Thuthikum adiyavaruku Oruvar Keduka Idar
Ninaikin avar Kulathai Muthal
arakkalaiyum Enaku Oore Thunai Aagum (Thiru)
39. Sinathu avuNar Ethirtharana Kalathil Vegu
Kuraithalaigal Siruthu eyiru
Kadithu Vizhi Vizhiththu alara Mothum (Thiru)
40. Panaikaimuga Padakarada Mathathavala
Gajakadavul Pathathu Idum Ni-
Kalathumulai Therikavaram Aagum (Thiru)
41. Thanithuvazhi Nadakkum Enathu idaththum Oru
Valatthum iru Purathum Arugu
Aduthu iravu Pagal thunayathu Aagum (Thiru)
42. Sudarpparithi Olippa Nilavu Ozhukkum Mathi
Olippa alai adakkuthazhl Olippa Olir
Olip prabai Veesum (Thiru)
43. Pazhuthamuthu Thamizhppalagai irukkum Oru
Kavipulavan Isaikku Urugi
Varaiguhaiyai idiththu Vazhi Kaanum (Thiru)
44. Thisaikkiriyai Mutharrkulisan aruthasirai
Mulaithathu ena Mugattin Idai
Parakka ara Visaiththu athira Oodum (Thiru)
45. Salathuvarum Arakar Udal Kozhuthu Valar
Peruthakudar Sivathathodai
Enasegaiyil Viruppamodu sUdum (Thiru)
46. Surarkkum Munivararkkum Magapathikumm Vithi
thanukumm ari thanakumm narar thamakumm Urum
idukkaN Vinai sAdum (Thiru)
47. Thiraikkadalai Udaithunerai Punarkkadithu
Kudithu Udaiyum Udaippu adaiya
adaithu Uthiram Niraithu Vilaiyadum (Thiru)
48. Pasithu alagai Musithu azhuthu Muraippaduthal
Ozhithu avuNar Urathu Uthira
NiNaththasaigal Pusika arul Nerum (Thiru)
49. Thiraikkadalai Udaithunerai Punarkkadithu
Kudithu Udaiyum Udaippu adaiya
adaithu Uthiram Niraithu Vilaiyadum (Thiru)
50. Pasithu alagai Musithu azhuthu Muraippaduthal
Ozhithu avuNar Urathu Uthira
NiNaththasaigal Pusika arul Nerum (Thiru)
51. Salathuvarum Arakar Udal Kozhuthu Valar
Peruthakudar Sivathathodai
Enasegaiyil Viruppamodu sUdum (Thiru)
52. Surarkkum Munivararkkum Magapathikumm Vithi
thanukumm ari thanakumm narar thamakumm Urum
idukkaN Vinai sAdum (Thiru)
53. Thisaikkiriyai Mutharrkulisan aruthasirai
Mulaithathu ena Mugattin Idai
Parakka ara Visaiththu athira Oodum (Thiru)
54. Pazhuthamuthu Thamizhppalagai irukkum Oru
Kavipulavan Isaikku Urugi
Varaiguhaiyai idiththu Vazhi Kaanum (Thiru)
55. Thanithuvazhi Nadakkum Enathu idaththum Oru
Valatthum iru Purathum Arugu
Aduthu iravu Pagal thunayathu Aagum (Thiru)
56. Sudarpparithi Olippa Nilavu Ozhukkum Mathi
Olippa alai adakkuthazhl Olippa Olir
Olip prabai Veesum (Thiru)
57. Sinathu avuNar Ethirtharana Kalathil Vegu
Kuraithalaigal Siruthu eyiru
Kadithu Vizhi Vizhiththu alara Mothum (Thiru)
58. Panaikaimuga Padakarada Mathathavala
Gajakadavul Pathathu Idum Ni-
Kalathumulai Therikavaram Aagum (Thiru)
59. Thalaththiluhla ganaththoguthi KalhippinuNa
Vazhaippathuena Malarkamala Karaththinmunai
Vithirka valhaivu Aagum (Thiru)
60. Thuthikum adiyavaruku Oruvar Keduka Idar
Ninaikin avar Kulathai Muthal
arakkalaiyum Enaku Oore Thunai Aagum (Thiru)
61. Thiruthaniyil Uthithu Arulum Oruthan Malai
Viruththan Enathu Ullathil Urai
Karuthan Mayil Nadaththu Guhan Velae (Thiru)
62. Paruthamulai Sirutha Idai Veluththanagai
Karuthakulal Sivaththa Ithazh Marasirumi
Vizhikku Nigar Aagum (Thiru)
63. Tharukkinaman Murukkavarin Erukkumathi
Tharithamudi Padaiththa Viral Padaiththa Irai
Kazharku Nigar Aagum (Thiru)
64. Sollarkku ariya Thirupugazhai Uraithavarai
aduthapagai aruththu eriya
Urukki Ezhum araththai nilai Kaanum (Thiru)
65. Thiruthaniyil Uthithu arulum Oruthan Malai
Virudthan Enathu Ullathil Urai
Karuthan Mayil Nadaththu Guhan Velae
[Recite The Last Stanza 12 Times Again To Complete It.]
"""
|> String.split("
")
|> Enum.map(fn << no::binary-size(2), verse::binary >> ->
{no |> String.trim() # Remove leading/trailing whitespace
|> String.replace(".", "") # Remove periods
|> String.to_integer(), (verse |> String.replace(".", "") |> String.trim())}
end)
|> Enum.into(%{})
# %{id: sid} = Vyasa.Written.get_source!("658dfbd6-3a01-46e7-a4ec-f0fe7b4b9c96")
# %Vyasa.Written.Chapter{source_id: sid, no: 1, title: "Vel Maaral", body: "Vel Maaral Maha Mantram is a powerful devotional chant dedicated to Lord Murugan, the Hindu god of war and victory. This unique recitation method, was compiled by Vallimalai Sri Sachchidananda Swamigal based on the first 16 verses of Vel Vaguppu, which was originally composed by Arunagirinathar"}
# |> Vyasa.Written.Chapter.changeset(%{"translations" => [%{"lang" => "en",
# "type" => "chapters",
# "target" => %{"title" => "Spear's Cause", "title_translit" => "Vel Maaral"}, "source_id" => sid}]})
# |> Vyasa.Repo.insert!()
# Vyasa.Written.get_chapters_by_src("vel maaral")
translation = """
All these praiseworthy feats are those of the Vel in the hands of the One who rises (like the Sun of Knowledge) at TiruththaNi and is the Old Man of the Hill, who resides in my heart and whose vehicle is the peacock.
The wide, deep and sharp Vel or Spear is like the eyes of the brave hunter lass Valli who has heavy bosoms, slender waist, gleaming white teeth, black tresses, and red lips.
All these praiseworthy feats are those of the Vel in the hands of the One who rises (like the Sun of Knowledge) at TiruththaNi and is the Old Man of the Hill, who resides in my heart and whose vehicle is the peacock.
The Spear upholds dharma by fiercely uprooting the bad karma that tries to sprout against those who chant the ineffably beautiful Tiruppugazh hymns with devotion and understanding of its profound meaning.
The Spear is as praiseworthy as the auspicious feet of the victorious Lord Shiva who wears arka (erukkam) flower and the crescent moon on His tresses and who offers sanctuary to the devotees when Yama approaches them arrogantly to take away their lives.
Murugan's vel is the saw that cuts through the locks on the chain that Surapadman put on the ankles of Indra whose vehicle is the white Airavata elephant with a trunk that is suspended like a palm tree, with its forehead caparisoned with decorative clothes and with cheeks down which flow the masth water.
The severed heads of the asuras in the battlefield mockingly laugh at those still advancing toward the Spear, provoking them to grind their teeth and glare in fury as they charge forward onto the Vel, only to be smashed and beheaded.
The Spear serves as a guardian, not only destroying the bad karma that tries to manifest against its devotees but also its entire chain of karmic consequences from its root, to protect those who worship it.
The Lord's lotus-like hands extend in an inviting gesture, with delicate fingertips warmly inviting those under His patronage—those hungry for His grace and wisdom—to partake in His infinite benevolence. In perfect harmony, the vel resting on His majestic shoulder bends gracefully, as if to shower divine grace, blessings, and knowledge upon all.
Murugan's vel pounded the Tirupparangiri mountain and rescued Nakkeeran and other poets from the cave (where they were imprisoned by a ghost called Karkimukhi) after being touched by the musical renderings of the peerless Nakkeeran, the head of the ancient Tamil Sangam board which is renowned for its knowledge.
The Spear flies with infinite swiftness across the the crest of the cosmic sphere making the universe quiver and appear as if all the mountains in the eight directions had regenerated their wings that were cut once by Indra.
The Spear radiates the brilliance of divine knowledge, casting such a resplendent light that even the radiant sun, the serene moon with its soothing rays, and the blazing Vadavamukhagni, which restrains the seas from engulfing the world, are humbled into hiding.
When I walk alone, the Spear is with me on all sides—before me, behind me, to my left and right, close by both in the day and night, offering me constant protection and companionship.
The Spear mercifully stops the hungry ghosts from crying aloud and complaining about the lack of food by giving them the blood-soaked fatty flesh of the asuras.
The Spear tears the wavy sea, closing the breach everywhere so that water is dammed; drinks it swiftly, and again fills it with the blood from the asuras and plays in it.
The Spear destroys the evils of karma that cause grief to celestials, sages, Indra, Brahma, Vishnu and the humans.
The Spear wears with delight on its crown, a red garland of the fatty intestines of the fat asuras who charge angrily in the battle field.
The Spear destroys the evils of karma that cause grief to celestials, sages, Indra, Brahma, Vishnu and the humans.
The Spear wears with delight on its crown, a red garland of the fatty intestines of the fat asuras who charge angrily in the battle field.
The Spear mercifully stops the hungry ghosts from crying aloud and complaining about the lack of food by giving them the blood-soaked fatty flesh of the asuras.
The Spear tears the wavy sea, closing the breach everywhere so that water is dammed; drinks it swiftly, and again fills it with the blood from the asuras and plays in it.
The Spear radiates the brilliance of divine knowledge, casting such a resplendent light that even the radiant sun, the serene moon with its soothing rays, and the blazing Vadavamukhagni, which restrains the seas from engulfing the world, are humbled into hiding.
When I walk alone, the Spear is with me on all sides—before me, behind me, to my left and right, close by both in the day and night, offering me constant protection and companionship.
Murugan's vel pounded the Tirupparangiri mountain and rescued Nakkeeran and other poets from the cave (where they were imprisoned by a ghost called Karkimukhi) after being touched by the musical renderings of the peerless Nakkeeran, the head of the ancient Tamil Sangam board which is renowned for its knowledge.
The Spear flies with infinite swiftness across the the crest of the cosmic sphere making the universe quiver and appear as if all the mountains in the eight directions had regenerated their wings that were cut once by Indra.
The Spear serves as a guardian, not only destroying the bad karma that tries to manifest against its devotees but also its entire chain of karmic consequences from its root, to protect those who worship it.
The Lord's lotus-like hands extend in an inviting gesture, with delicate fingertips warmly inviting those under His patronage—those hungry for His grace and wisdom—to partake in His infinite benevolence. In perfect harmony, the vel resting on His majestic shoulder bends gracefully, as if to shower divine grace, blessings, and knowledge upon all.
Murugan's vel is the saw that cuts through the locks on the chain that Surapadman put on the ankles of Indra whose vehicle is the white Airavata elephant with a trunk that is suspended like a palm tree, with its forehead caparisoned with decorative clothes and with cheeks down which flow the masth water.
The severed heads of the asuras in the battlefield mockingly laugh at those still advancing toward the Spear, provoking them to grind their teeth and glare in fury as they charge forward onto the Vel, only to be smashed and beheaded.
The Spear upholds dharma by fiercely uprooting the bad karma that tries to sprout against those who chant the ineffably beautiful Tiruppugazh hymns with devotion and understanding of its profound meaning.
The Spear is as praiseworthy as the auspicious feet of the victorious Lord Shiva who wears arka (erukkam) flower and the crescent moon on His tresses and who offers sanctuary to the devotees when Yama approaches them arrogantly to take away their lives.
The wide, deep and sharp Vel or Spear is like the eyes of the brave hunter lass Valli who has heavy bosoms, slender waist, gleaming white teeth, black tresses, and red lips.
All these praiseworthy feats are those of the Vel in the hands of the One who rises (like the Sun of Knowledge) at TiruththaNi and is the Old Man of the Hill, who resides in my heart and whose vehicle is the peacock.
The Spear is as praiseworthy as the auspicious feet of the victorious Lord Shiva who wears arka (erukkam) flower and the crescent moon on His tresses and who offers sanctuary to the devotees when Yama approaches them arrogantly to take away their lives.
The Spear upholds dharma by fiercely uprooting the bad karma that tries to sprout against those who chant the ineffably beautiful Tiruppugazh hymns with devotion and understanding of its profound meaning.
All these praiseworthy feats are those of the Vel in the hands of the One who rises (like the Sun of Knowledge) at TiruththaNi and is the Old Man of the Hill, who resides in my heart and whose vehicle is the peacock.
The wide, deep and sharp Vel or Spear is like the eyes of the brave hunter lass Valli who has heavy bosoms, slender waist, gleaming white teeth, black tresses, and red lips.
The Lord's lotus-like hands extend in an inviting gesture, with delicate fingertips warmly inviting those under His patronage—those hungry for His grace and wisdom—to partake in His infinite benevolence. In perfect harmony, the vel resting on His majestic shoulder bends gracefully, as if to shower divine grace, blessings, and knowledge upon all.
The Spear serves as a guardian, not only destroying the bad karma that tries to manifest against its devotees but also its entire chain of karmic consequences from its root, to protect those who worship it.
The severed heads of the asuras in the battlefield mockingly laugh at those still advancing toward the Spear, provoking them to grind their teeth and glare in fury as they charge forward onto the Vel, only to be smashed and beheaded.
Murugan's vel is the saw that cuts through the locks on the chain that Surapadman put on the ankles of Indra whose vehicle is the white Airavata elephant with a trunk that is suspended like a palm tree, with its forehead caparisoned with decorative clothes and with cheeks down which flow the masth water.
When I walk alone, the Spear is with me on all sides—before me, behind me, to my left and right, close by both in the day and night, offering me constant protection and companionship.
The Spear radiates the brilliance of divine knowledge, casting such a resplendent light that even the radiant sun, the serene moon with its soothing rays, and the blazing Vadavamukhagni, which restrains the seas from engulfing the world, are humbled into hiding.
Murugan's vel pounded the Tirupparangiri mountain and rescued Nakkeeran and other poets from the cave (where they were imprisoned by a ghost called Karkimukhi) after being touched by the musical renderings of the peerless Nakkeeran, the head of the ancient Tamil Sangam board which is renowned for its knowledge.
The Spear wears with delight on its crown, a red garland of the fatty intestines of the fat asuras who charge angrily in the battle field.
The Spear destroys the evils of karma that cause grief to celestials, sages, Indra, Brahma, Vishnu and the humans.
The Spear tears the wavy sea, closing the breach everywhere so that water is dammed; drinks it swiftly, and again fills it with the blood from the asuras and plays in it.
The Spear mercifully stops the hungry ghosts from crying aloud and complaining about the lack of food by giving them the blood-soaked fatty flesh of the asuras.
The Spear tears the wavy sea, closing the breach everywhere so that water is dammed; drinks it swiftly, and again fills it with the blood from the asuras and plays in it.
The Spear mercifully stops the hungry ghosts from crying aloud and complaining about the lack of food by giving them the blood-soaked fatty flesh of the asuras.
The Spear wears with delight on its crown, a red garland of the fatty intestines of the fat asuras who charge angrily in the battle field.
The Spear destroys the evils of karma that cause grief to celestials, sages, Indra, Brahma, Vishnu and the humans.
The Spear flies with infinite swiftness across the the crest of the cosmic sphere making the universe quiver and appear as if all the mountains in the eight directions had regenerated their wings that were cut once by Indra.
Murugan's vel pounded the Tirupparangiri mountain and rescued Nakkeeran and other poets from the cave (where they were imprisoned by a ghost called Karkimukhi) after being touched by the musical renderings of the peerless Nakkeeran, the head of the ancient Tamil Sangam board which is renowned for its knowledge.
When I walk alone, the Spear is with me on all sides—before me, behind me, to my left and right, close by both in the day and night, offering me constant protection and companionship.
The Spear radiates the brilliance of divine knowledge, casting such a resplendent light that even the radiant sun, the serene moon with its soothing rays, and the blazing Vadavamukhagni, which restrains the seas from engulfing the world, are humbled into hiding.
The severed heads of the asuras in the battlefield mockingly laugh at those still advancing toward the Spear, provoking them to grind their teeth and glare in fury as they charge forward onto the Vel, only to be smashed and beheaded.
Murugan's vel is the saw that cuts through the locks on the chain that Surapadman put on the ankles of Indra whose vehicle is the white Airavata elephant with a trunk that is suspended like a palm tree, with its forehead caparisoned with decorative clothes and with cheeks down which flow the masth water.
The Lord's lotus-like hands extend in an inviting gesture, with delicate fingertips warmly inviting those under His patronage—those hungry for His grace and wisdom—to partake in His infinite benevolence. In perfect harmony, the vel resting on His majestic shoulder bends gracefully, as if to shower divine grace, blessings, and knowledge upon all.
The Spear serves as a guardian, not only destroying the bad karma that tries to manifest against its devotees but also its entire chain of karmic consequences from its root, to protect those who worship it.
All these praiseworthy feats are those of the Vel in the hands of the One who rises (like the Sun of Knowledge) at TiruththaNi and is the Old Man of the Hill, who resides in my heart and whose vehicle is the peacock.
The wide, deep and sharp Vel or Spear is like the eyes of the brave hunter lass Valli who has heavy bosoms, slender waist, gleaming white teeth, black tresses, and red lips.
The Spear is as praiseworthy as the auspicious feet of the victorious Lord Shiva who wears arka (erukkam) flower and the crescent moon on His tresses and who offers sanctuary to the devotees when Yama approaches them arrogantly to take away their lives.
The Spear upholds dharma by fiercely uprooting the bad karma that tries to sprout against those who chant the ineffably beautiful Tiruppugazh hymns with devotion and understanding of its profound meaning.
All these praiseworthy feats are those of the Vel in the hands of the One who rises (like the Sun of Knowledge) at TiruththaNi and is the Old Man of the Hill, who resides in my heart and whose vehicle is the peacock.
"""
|> String.split("
")
|> Enum.reduce({[], 0}, fn v, {acc, no} -> {[{no, v} | acc], no+1} end)
|> elem(0)
|> Enum.into(%{})
Vyasa.Written.get_verses_in_chapter(1, "658dfbd6-3a01-46e7-a4ec-f0fe7b4b9c96")
|> Vyasa.Repo.preload([:translations])
|> Enum.map(fn x ->
Enum.map(x.translations, fn x ->
Vyasa.Repo.delete!(x)
end)
Vyasa.Repo.delete!(x) end)
sid = "658dfbd6-3a01-46e7-a4ec-f0fe7b4b9c96"
verse |> Enum.map(fn {no, verse} ->
%Vyasa.Written.Verse{no: no, source_id: sid, chapter_no: 1, body: verse}
|> Vyasa.Written.Verse.changeset(%{"translations" => [%{"lang" => "en",
"type" => "verses",
"target" => %{"body_translit" => translit[no],
"body" => translation[no]},
"source_id" => sid}]})
|> Vyasa.Repo.insert!()
end)
sid
Vyasa.Written.get_chapters_by_src("vel_maaral")
import Ecto.Query, warn: false
from(c in Vyasa.Written.Verse,
where: c.source_id == ^sid)
|> Vyasa.Repo.all()
SAAVN
link =
"https://saavn.dev/api/albums?link=https://www.jiosaavn.com/album/thiruvasagam-vol-1-to-6/M2txfVKHMQ0_"
p =
Finch.build(:get, link)
|> Finch.request!(Vyasa.Finch)
defmodule Vyasa.Stream do
def stream([{_url, _path} | _] = data) do
Task.async_stream(
data,
fn {url, path} ->
download(url, path)
end,
timeout: :infinity
)
end
def download(url, file_path) do
IO.puts("Starting to process #{inspect(file_path)}...........")
# Open a file to which binary chunks will be appended to.
# this process is reset in case of redirection
file_pid = File.open!(file_path, [:write, :binary])
unless is_pid(file_pid), do: raise("File creation problem on disk")
# the HTTP stream request
Finch.build(:get, url)
|> Finch.stream_while(Vyasa.Finch, nil, fn
# we put the status in the "acc" to handle redirections
{:status, status}, _acc ->
{:cont, status}
# - when we receive 302, we put the "location" header in the "acc"
# - when we receive a 200, we put the "content-length" and the file name in the "acc",
{:headers, headers}, acc ->
handle_headers(headers, acc)
# when we receive the "location" tuple, we recurse
# otherwise, we write the chunk into the file and print out the current progress.
{:data, data}, acc ->
handle_data(data, acc, file_path, file_pid)
end)
case File.close(file_pid) do
:ok ->
{:halt, {file_path, :done}}
{:error, _reason} ->
{:halt, :error}
end
end
def handle_headers(headers, status) when status in [301, 302, 303, 307, 308] do
IO.puts("REDIR: #{status}")
{:cont, Enum.find(headers, &(elem(&1, 0) == "location"))}
end
def handle_headers(headers, 200) do
{"content-length", size} =
Enum.find(headers, &(elem(&1, 0) == "content-length"))
case size do
nil ->
{:cont, {0, 0}}
size ->
{:cont, {0, String.to_integer(size)}}
end
end
def handle_headers(_, status) do
dbg(status)
{:halt, :bad_status}
end
def handle_data(_data, {"location", location}, file_path, file_pid) do
if Process.alive?(file_pid), do: :ok = File.close(file_pid)
# recursion
download(location, file_path)
end
def handle_data(data, {processed, size}, file_path, file_pid) do
case IO.binwrite(file_pid, data) do
:ok ->
processed =
if is_integer(size) and size > 0 do
(processed + byte_size(data))
|> tap(fn processed ->
IO.inspect(Float.round(processed * 100 / size, 1),
label: "Processed #{inspect(file_path)} %: "
)
end)
else
processed + byte_size(data)
end
{:cont, {processed, size}}
{:error, reason} ->
{:error, reason}
end
end
end
path = "#{File.cwd!()}/media/thiruvasagam/"
Application.ensure_all_started(:inets)
data =
p
|> Map.get(:body)
|> Jason.decode!()
|> Map.get("data")
|> Map.get("songs")
# |> List.first()
|> Enum.map(fn %{"downloadUrl" => urls, "name" => name} ->
url = urls |> Enum.reverse() |> hd() |> Map.get("url")
{url, path <> name}
end)
# |> Task.async_stream((fn {url, name} ->
# Vyasa.Stream.download(url, path <> name)
# end), timeout: :infinity)
|> Vyasa.Stream.stream()
|> Stream.run()
GUPOPE
link = "https://www.projectmadurai.org/pm_etexts/utf8/pmuni0094.html"
p =
Finch.build(:get, link)
|> Finch.request!(Vyasa.Finch)
|> Map.get(:body)
|> Floki.parse_document!()
|> Floki.find("body")
|> tap(&IO.inspect(&1, limit: :infinity))
# [{"body", [], body , something}] =p
b = p |> List.first()
{"body", [], body} = b
ts =
body
|> Enum.reduce({-1, %{}, []}, fn
# Clear window and start new chapter
{"h3", _, chapter}, {curr, acc, win} when is_list(chapter) ->
IO.inspect(win, label: "remaining window")
{curr + 1, Map.put(acc, curr + 1, %{chapter: List.last(chapter), verse: []}), []}
{"h3", _, chapter}, {curr, acc, win} ->
IO.inspect(win, label: "remaining window")
{curr + 1, Map.put(acc, curr + 1, %{chapter: chapter}), []}
# New value in topic, add appropriate topic_map to topic_maps in accumulator
{"center", [], [{"h3", [], list}]}, acc ->
acc
{_, _, _}, acc ->
# other translations not today
acc
line, {curr, acc, win} ->
IO.inspect(line, label: "caught")
newin =
case Regex.run(~r/\s*(\(?\d+\)?)\s*$/, line) do
[_, verse_number] ->
verse_number = String.replace(verse_number, "(", "") |> String.replace(")", "")
verse_number = String.trim(verse_number)
f_l =
line
|> String.replace(~r/\s*\(?\d+\)?\s*/, "")
|> String.trim()
# Allocate the verse to the corresponding number
[{String.to_integer(verse_number), f_l} | win]
_ ->
# If no verse number, just accumulate the line
[{nil, line} | win]
end
{curr, acc, newin}
end)
{last, map, win} = ts
{count, _, v} =
[:END | win]
|> Enum.reverse()
|> Enum.reduce({0, [], %{}}, fn
{verse_number, text}, {curr, rem, acc} when is_number(verse_number) ->
{_, verses} =
rem
|> Enum.reverse()
|> Enum.reduce_while({verse_number, acc}, fn
x, {count, acc} when count > curr ->
case Regex.match?(~r/^[A-Z\s'!@#$%^&*()_+={}\[\]:;"'<>,.?\/\\-]+$/, x) do
false ->
{:cont,
{count - 1, Map.update(acc, count - 1, x, fn existing -> [x | existing] end)}}
_ ->
{:cont, {count, acc}}
end
x, {_, acc} ->
{:halt, acc}
end)
{verse_number, [],
Map.update(verses, verse_number, text, fn existing -> [text | existing] end)}
{nil, text}, {curr, rem, acc} when length(rem) > 4 ->
{curr, [text | rem |> Enum.reverse() |> tl() |> Enum.reverse()], acc}
{nil, text}, {curr, rem, acc} ->
{curr, [text | rem], acc}
:END, {curr, rem, acc} ->
{_, terminal} =
rem
|> Enum.reverse()
|> Enum.reduce({curr, acc}, fn x, {count, acc} ->
{count + 1, Map.update(acc, count + 1, x, fn existing -> [x | existing] end)}
end)
{curr, [], terminal}
end)
v
# |> Enum.map(fn {verse_number, texts} ->
# {verse_number, Enum.reverse(texts)}
# end)
Vyasa.Written.get_verses_in_chapter(1, "fcdacf6d-9d2d-4cf5-9a27-a8ef39011d7b")
|> Enum.map(fn %{no: verse_no, id: verse_id} ->
#Vyasa.Written.create_translation(%{"type" => "verses", "lang" => "en", "verse_id" => verse_id})
{verse_no, v[verse_no]}
end)
Thiruvaasagam
url = "https://www.sivaya.org/"
# fetch from root frame
path = "thiruvaasagam_complete.php"
doc = "?lang=english"
col =
Finch.build(:get, url <> path <> doc)
|> Finch.request!(Vyasa.Finch)
|> Map.get(:body)
|> Floki.parse_document!()
|> Floki.find("body")
|> tap(&IO.inspect(&1, limit: :infinity))
defmodule ThiruvaasagamScraper do
@base_url "https://www.sivaya.org/thiruvaasagam_complete.php"
def scrape(lang) do
{:ok, html} =
Finch.build(:get, @base_url <> "?lang=" <> lang)
|> Finch.request!(Vyasa.Finch)
|> Map.get(:body)
|> Floki.parse_document()
chapters = extract_chapters(html, lang)
%{chapters: chapters}
end
def extract_chapters(html, lang) do
html
|> Floki.find("a[href^='thirumurai_song.php?&pathigam_no=8.']")
|> Enum.map(&extract_chapter(&1, lang))
end
defp extract_chapter(chapter_link, lang) do
href = Floki.attribute(chapter_link, "href")
chapter_number =
href
|> List.first()
|> extract_chapter_number()
chapter_title = Floki.text(chapter_link)
# verses = extract_verses(chapter_number, lang)
%{
number: chapter_number,
title: chapter_title,
url: href
# verses: verses
}
end
defp extract_chapter_number(href) do
Regex.run(~r/pathigam_no=8\.(\d+)/, href)
|> List.last()
|> String.to_integer()
end
def extract_verses(chapter_number, lang) when is_number(chapter_number) do
chapter_url =
"thirumurai_song.php?&pathigam_no=8.#{chapter_number}&lang=" <> lang
extract_verses(chapter_url)
end
def extract_verses(chapter_url) when is_binary(chapter_url) do
{:ok, chapter_html} =
Finch.build(:get, "https://www.sivaya.org/" <> chapter_url)
|> Finch.request!(Vyasa.Finch)
|> Map.get(:body)
|> Floki.parse_document()
chapter_html
|> Floki.find("table td")
|> extract_verse_texts()
end
defp extract_verse_texts(td) do
td
|> Enum.reduce([], fn
{"td", [],
[
{"a", [{"id", _}], []},
links,
_
]} = td,
acc ->
[links | acc]
_, acc ->
acc
end)
|> Enum.reverse()
|> Enum.map(
&(Floki.text(&1)
|> String.split("\n\n")
|> Enum.reject(fn
"" -> true
_ -> false
end))
)
|> List.flatten()
end
end
e_v = ThiruvaasagamScraper.extract_verses(101, "english")
t_v = ThiruvaasagamScraper.extract_verses(101, "tamil")
# %Vyasa.Written.Source{
# title: "Thiruvasagam",
# verses: (for i <- 0..length(t_v) do
# %Vyasa.Written.Verse{no: i, body: Enum.at(t_v, i), translations: (for i <- 0..length(e_v) do
# %Vyasa.Written.Translation{lang: "en", body: Enum.at(t_v, i)}
# end)}
# end)
# }
# %Vyasa.Written.Source{}
# |> Vyasa.Written.Source.gen_changeset(%{title: "Thiruvasagam", chapters: })
chapters_e = ThiruvaasagamScraper.scrape("english")
chapters_t = ThiruvaasagamScraper.scrape("tamil")
%{id: sid} =
source =
%Vyasa.Written.Source{}
|> Vyasa.Written.Source.gen_changeset(%{title: "thiruvasagam", lang: "ta"})
|> Vyasa.Repo.insert!()
c_t =
chapters_t[:chapters]
|> Enum.reduce(
[],
fn
%{number: no, title: title, url: [url]}, [%{number: curr_no, url: curr_url} = curr | acc]
when no == curr_no + 100 ->
[Map.put(curr, :url, [url | curr_url]) | acc]
%{number: no, title: title, url: url}, acc ->
[
%{
no: no - 100,
title:
String.split(title, "-")
|> List.first()
|> String.split(" ")
|> List.last()
|> String.trim(),
url: url,
source_id: sid
}
| acc
]
end
)
|> Enum.map(fn %{url: url} = c ->
Map.put(
c,
:verses,
url
|> Enum.map(fn u ->
ThiruvaasagamScraper.extract_verses(u)
end)
|> List.flatten()
|> Enum.reduce({1, []}, fn x, {count, verses} ->
{count + 1, [%{no: count, body: x, source_id: sid} | verses]}
end)
|> elem(1)
)
end)
chapters =
c_t
|> Enum.uniq(& &1.no)
|> Enum.map(fn c ->
%Vyasa.Written.Chapter{source_id: sid}
|> Vyasa.Written.Chapter.changeset(c)
|> Vyasa.Repo.insert!()
end)
Vyasa.Written.get_source!("219f1767-6018-45af-9567-0a3fe52671af")
ThiruvaasagamScraper.extract_verses("thirumurai_song.php?&pathigam_no=8.101&lang=tamil")
t_v = ThiruvaasagamScraper.extract_verses(101, "hindi")
GUPOPE
link = "https://www.projectmadurai.org/pm_etexts/utf8/pmuni0094.html"
p =
Finch.build(:get, link)
|> Finch.request!(Vyasa.Finch)
|> Map.get(:body)
|> Floki.parse_document!()
|> Floki.find("body")
|> tap(&IO.inspect(&1, limit: :infinity))
# [{"body", [], body , something}] =p
b = p |> List.first()
{"body", [], body} = b
ts =
body
|> Enum.reduce({-1, %{}, []}, fn
# Clear window and start new chapter
{"h3", _, chapter}, {curr, acc, win} when is_list(chapter) ->
IO.inspect(win, label: "remaining window")
{curr + 1, Map.put(acc, curr + 1, %{chapter: List.last(chapter), verse: []}), []}
{"h3", _, chapter}, {curr, acc, win} ->
IO.inspect(win, label: "remaining window")
{curr + 1, Map.put(acc, curr + 1, %{chapter: chapter}), []}
# New value in topic, add appropriate topic_map to topic_maps in accumulator
{"center", [], [{"h3", [], list}]}, acc ->
acc
{_, _, _}, acc ->
# other translations not today
acc
line, {curr, acc, win} ->
newin =
case Regex.run(~r/\s*(\(?\d+\)?)\s*$/, line) do
[_, verse_number] ->
verse_number = String.replace(verse_number, "(", "") |> String.replace(")", "")
verse_number = String.trim(verse_number)
f_l =
line
|> String.replace(~r/\s*\(?\d+\)?\s*/, "")
|> String.trim()
# Allocate the verse to the corresponding number
[{String.to_integer(verse_number), f_l} | win]
_ ->
# If no verse number, just accumulate the line
[{nil, line} | win]
end
{curr, acc, newin}
end)
{last, map, win} = ts
win
|> Enum.reverse()
|> Enum.reduce({0, %{}}, fn
{verse_number, text}, {curr, acc} when is_number(verse_number) ->
{verse_number, Map.update(acc, verse_number, text, fn existing -> [text | existing] end)}
{nil, text}, {curr, acc} ->
{curr + 1, Map.update(acc, curr + 1, text, fn existing -> [text | existing] end)}
end)
# |> Enum.map(fn {verse_number, texts} ->
# {verse_number, Enum.reverse(texts)}
# end)
Thiruvaasagam
url = "https://www.sivaya.org/"
# fetch from root frame
path = "thiruvaasagam_complete.php"
doc = "?lang=english"
col =
Finch.build(:get, url <> path <> doc)
|> Finch.request!(Vyasa.Finch)
|> Map.get(:body)
|> Floki.parse_document!()
|> Floki.find("body")
|> tap(&IO.inspect(&1, limit: :infinity))
defmodule ThiruvaasagamScraper do
@base_url "https://www.sivaya.org/thiruvaasagam_complete.php"
def scrape(lang) do
{:ok, html} =
Finch.build(:get, @base_url <> "?lang=" <> lang)
|> Finch.request!(Vyasa.Finch)
|> Map.get(:body)
|> Floki.parse_document()
chapters = extract_chapters(html, lang)
%{chapters: chapters}
end
def extract_chapters(html, lang) do
html
|> Floki.find("a[href^='thirumurai_song.php?&pathigam_no=8.']")
|> Enum.map(&extract_chapter(&1, lang))
end
defp extract_chapter(chapter_link, lang) do
href = Floki.attribute(chapter_link, "href")
chapter_number =
href
|> List.first()
|> extract_chapter_number()
chapter_title = Floki.text(chapter_link)
# verses = extract_verses(chapter_number, lang)
%{
number: chapter_number,
title: chapter_title,
url: href
# verses: verses
}
end
defp extract_chapter_number(href) do
Regex.run(~r/pathigam_no=8\.(\d+)/, href)
|> List.last()
|> String.to_integer()
end
def extract_verses(chapter_number, lang) when is_number(chapter_number) do
chapter_url =
"https://www.sivaya.org/thirumurai_song.php?&pathigam_no=8.#{chapter_number}&lang=" <> lang
extract_verses(chapter_url, lang)
end
def extract_verses(chapter_url, lang) when is_binary(chapter_url) do
{:ok, chapter_html} =
Finch.build(:get, chapter_url)
|> Finch.request!(Vyasa.Finch)
|> Map.get(:body)
|> Floki.parse_document()
chapter_html
|> Floki.find("table td")
|> extract_verse_texts()
end
defp extract_verse_texts(td) do
td
|> Enum.reduce([], fn
{"td", [],
[
{"a", [{"id", _}], []},
links,
_
]} = td,
acc ->
[links | acc]
_, acc ->
acc
end)
|> Enum.reverse()
|> Enum.map(
&(Floki.text(&1)
|> String.split("\n\n")
|> Enum.reject(fn
"" -> true
_ -> false
end))
)
|> List.flatten()
end
end
e_v = ThiruvaasagamScraper.extract_verses(101, "english")
t_v = ThiruvaasagamScraper.extract_verses(101, "tamil")
# %Vyasa.Written.Source{
# title: "Thiruvasagam",
# verses: (for i <- 0..length(t_v) do
# %Vyasa.Written.Verse{no: i, body: Enum.at(t_v, i), translations: (for i <- 0..length(e_v) do
# %Vyasa.Written.Translation{lang: "en", body: Enum.at(t_v, i)}
# end)}
# end)
# }
# %Vyasa.Written.Source{}
# |> Vyasa.Written.Source.gen_changeset(%{title: "Thiruvasagam", chapters: })
chapters_e = ThiruvaasagamScraper.scrape("english")
chapters_t = ThiruvaasagamScraper.scrape("tamil")
chapters_e[:chapters]
|> Enum.reduce(
[],
fn
%{number: no, title: title, url: [url]}, [%{number: curr_no, url: curr_url} = curr | acc]
when no == curr_no + 100 ->
[Map.put(curr, :url, [url | curr_url]) | acc]
%{number: no, title: title, url: url}, acc ->
[
%{
number: no - 100,
title:
String.split(title, "-")
|> List.first()
|> String.split(" ")
|> List.last()
|> String.trim(),
url: url
}
| acc
]
end
)
|> Enum.find(&(&1.number == 1))
chapters_e
t_v = ThiruvaasagamScraper.extract_verses(101, "hindi")
Valmiki Ramayana
url = "https://www.valmikiramayan.net/utf8/"
# fetch from root frame
path = "baala/sarga1/"
doc = "balasans1.htm"
col =
Finch.build(:get, url <> path <> doc)
|> Finch.request!(Vyasa.Finch)
|> Map.get(:body)
|> Floki.parse_document!()
|> Floki.find("body")
|> List.first()
|> elem(2)
defmodule Rama do
# audio n+1
def parse(data, acc) do
case {data, acc} do
{{"p", [{"class", "SanSloka"}], [{"audio", _, _} | _] = audio},
[%{"count" => c} = curr | _] = acc} ->
# IO.inspect(audio, label: "audio")
[src] =
audio
|> Floki.find("source")
|> Floki.attribute("src")
[
curr
|> Map.put("count", c + 1)
|> Map.put("audio", src)
| acc
]
{{"p", [{"class", "SanSloka"}], [{"audio", _, _} | _] = audio}, []} ->
[src] =
audio
|> Floki.find("source")
|> Floki.attribute("src")
[%{"count" => 1, "audio" => src}]
# verse n + 1
{{"p", [{"class", "SanSloka"}], verses}, [curr | acc]} ->
[Map.put(curr, "verse", verses |> Floki.text() |> String.trim()) | acc]
# nesting in verloc
{{"p", [{"class", "verloc"}], [{"p", [{"class", "SanSloka"}], sloka} | _] = ns_tree},
[curr | _] = acc}
when is_map(curr) ->
# IO.inspect(ns_tree)
# IO.inspect(ns_tree)
Enum.reduce(ns_tree, acc, &parse/2)
{{"p", [{"class", "verloc"}], rem} = c_tree, [curr | acc]} when is_map(curr) ->
[curr | acc]
# # n case before verse break
{{"p", [{"class", class}], _} = c_tree, [curr | acc]} when is_map(curr) ->
[Map.put(curr, class, c_tree |> Floki.text() |> String.trim()) | acc]
{para, acc} ->
# IO.inspect(para, label: "div")
acc
end
end
end
output =
col
|> Enum.reduce([], &Rama.parse/2)
# # formatting & tying loose ends
# clean_verses =
# [Map.put(curr, "count", count + 1) | verses]
# |> Enum.reverse()
File.mkdir_p!(Path.expand(path, "media"))
output
|> Enum.reduce([], fn
%{"audio" => aud, "count" => 12 = count, "verse" => verse}, acc ->
aud_bin =
Finch.build(
:get,
Path.join(url <> path, aud)
|> String.replace(~r/\.\//, "")
)
|> Finch.request!(Vyasa.Finch)
|> Map.get(:body)
m_path = Path.expand(path <> "/#{count}.mp3", "media")
File.write!(m_path, aud_bin)
{:ok,
%Vyasa.Parser.MP3{
duration: d,
path: p,
title: title
}} = Vyasa.Parser.MP3.parse(m_path)
[
%Vyasa.Medium.Event{
origin: 0,
duration: d,
fragments: [%{status: "firstpass", quote: verse}]
}
| acc
]
_, acc ->
acc
end)
aud =
output
|> Enum.find(&(Map.get(&1, "count") == 1))
|> Map.get("audio")
aud_bin =
Finch.build(
:get,
Path.join(url <> path, aud)
|> String.replace(~r/\.\//, "")
)
|> Finch.request!(Vyasa.Finch)
|> Map.get(:body)
# # IO.binwrite(path, aud)
# # |> :file.read_file_info()
# File.open(Path.expand([path,aud], "media"), [:write, :binary])
# # |> IO.binwrite(aud_bin)
# Path.expand([path,aud], "media")
# # |> File.touch!()
File.mkdir_p!(Path.expand(path, "media"))
{:ok, file} = File.write!(Path.expand(path, "media"), aud_bin)
Shlokam
url = "https://shlokam.org/"
path = "hanumanchalisa"
col =
Finch.build(:get, url <> path)
|> Finch.request!(Vyasa.Finch)
|> Map.get(:body)
|> Floki.parse_document!()
|> Floki.find(".uncode_text_column")
# class_key = %{
# "verse_meaning" => "en_translation",
# "verse_sanskrit" => "text",
# "verse_trans" => "transliteration",
# }
output =
col
|> Enum.reduce(%{title: nil, description: nil, verses: []}, fn
{"div", _, [{"h3", [], ["Description"]} | para]}, acc ->
# IO.inspect(rem, label: "div")
desc =
para
|> Floki.text()
%{acc | description: desc}
{"div", _, [{"h3", _, _} = h3_tree]}, acc ->
title =
h3_tree
|> Floki.text()
%{acc | title: title}
{"div", _, [{"div", [{"class", "verse_sanskrit"}], _verse} | _] = verse_tree}, acc ->
[curr | [%{"count" => count} | _] = verses] =
Enum.reduce(verse_tree, [], fn
# n case verse break
{"hr", [{"class", "verse_separator"}], []}, [curr | [%{"count" => c} | _] = acc] ->
[Map.put(curr, "count", c + 1) | acc]
# init verse break
{"hr", [{"class", "verse_separator"}], []}, [curr | acc] ->
[Map.put(curr, "count", 1) | acc]
# n case after verse break
{"div", [{"class", class}], _} = c_tree, [%{"count" => _} | _] = acc ->
[%{class => c_tree |> Floki.text()} | acc]
# n case before verse break
{"div", [{"class", class}], _} = c_tree, [curr | acc] when is_map(curr) ->
[Map.put(curr, class, c_tree |> Floki.text()) | acc]
# init
{"div", [{"class", class}], _} = c_tree, [] ->
[%{class => c_tree |> Floki.text()}]
others, acc ->
IO.inspect(others)
acc
end)
# formatting & tying loose ends
clean_verses =
[Map.put(curr, "count", count + 1) | verses]
|> Enum.reverse()
%{acc | verses: clean_verses}
_, acc ->
acc
end)
contents = Poison.encode!(output)
# File.write!("chalisa_scraped.json", contents)
filename = "chalisa_scraped.json"
url = "./Projects/vyasa/scripts/#{filename}"
File.write!(url, contents)
IO.puts(url)
Floki.traverse_and_update(html, fn
{"div", _, _} = node -> {"div", [], ["Modified Div"]}
node -> node
end)
text = find_element(:class, "verse_sanskrit") |> inner_text()
transliteration = find_element(:class, "verse_trans") |> inner_text()
en_translation = find_element(:class, "verse_meaning") |> inner_text()
map = %{
verse_number: count,
text: text,
transliteration: transliteration,
en_translation: en_translation
}
Gita Events
gita = Vyasa.Written.get_source_by_title("Gita")
verses = Vyasa.Written.get_verses_in_chapter(1, gita.id)
verse_lookup = Enum.into(for(%{id: id, no: verse_no} <- verses, do: {verse_no, id}), %{})
c1_path = Path.expand("./1.mp3", "media/gita")
{:ok,
%Vyasa.Parser.MP3{
duration: tot_d,
path: p
}} = Vyasa.Parser.MP3.parse(c1_path)
{:ok, voice} =
Vyasa.Medium.create_voice(%{lang: "sa", duration: tot_d, file_path: c1_path, source_id: gita.id})
# Vyasa.Medium.get_voice!("4c73fb6d-4163-4b64-90d0-5d49680c1ee4")
# |> Vyasa.Medium.delete_voice()
"""
start :- 00:00
Shloka 1:- 00:33
Shloka 2 :- 00:49
Shloka 3:- 01:06
Shloka 4:- 01:19
Shloka 5:- 01:32
Shloka 6:- 01:46
Shloka 7:- 02:00
Shloka 8:- 02:15
Shloka 9:- 02:28
Shloka 10:- 02:42
Shloka 11:- 02:56
Shloka 12:- 03:09
Shloka 13:- 03:22
Shloka 14:- 03:36
Shloka 15:- 03:49
Shloka 16:- 04:02
Shloka 17:- 04:14
Shloka 18:- 04:27
Shloka 19:- 04:40
Shloka 20:- 04:54
Shloka 21:- 05:07
Shloka 22:- 05:23
Shloka 23:- 05:36
Shloka 24:- 05:50
Shloka 25:- 06:05
Shloka 26:- 06:18
Shloka 27:- 06:32
Shloka 28:- 06:46
Shloka 29:- 07:01
Shloka 30:- 07:13
Shloka 31:- 07:26
Shloka 32 :- 07:38
Shloka 33:- 07:52
Shloka 34 :- 08:05
Shloka 35 :- 08:18
Shloka 36 :- 08:31
Shloka 37:- 08:44
Shloka 38 :- 08:57
Shloka 39:- 09:09
Shloka 40:- 09:22
Shloka 41:- 09:35
Shloka 42:- 09:48
Shloka 43:- 10:02
Shloka 44:- 10:16
Shloka 45:- 10:29
Shloka 46:- 10:40
Shloka 47:- 10:53
end:- 11:08
"""
|> String.split("\n")
|> Enum.map(fn x ->
x
|> String.split(":-")
|> Enum.map(&String.trim/1)
|> Enum.reduce([], fn
<<"Shloka"::utf8, sep::utf8, verse_no::binary>>, acc ->
[verse_lookup[String.to_integer(verse_no)] | acc]
bin, acc ->
[bin | acc]
end)
end)
|> IO.inspect(limit: :infinity)
|> Enum.reduce(
[],
fn
[time, "start"], acc ->
[%Vyasa.Medium.Event{origin: 0, phase: "start", voice_id: voice.id} | acc]
[time, "end"], [%{origin: o} = prev | acc] ->
[min, sec] = time |> String.split(":") |> Enum.map(&String.to_integer/1)
d = (min * 60 + sec) * 1000
[
%Vyasa.Medium.Event{origin: d, duration: tot_d - d, phase: "end", voice_id: voice.id}
| [%{prev | duration: d - o} | acc]
]
[time, id], [%{origin: o} = prev | acc] ->
[min, sec] = time |> String.split(":") |> Enum.map(&String.to_integer/1)
d = (min * 60 + sec) * 1000
[
%Vyasa.Medium.Event{origin: d, verse_id: id, voice_id: voice.id}
| [%{prev | duration: d - o} | acc]
]
_, acc ->
acc
end
)
|> Enum.map(&Vyasa.Medium.create_event(&1))