Change everything to camelCase
authorJoseph Nuthalapati <njoseph@riseup.net>
Sat, 5 Oct 2019 07:12:40 +0000 (12:42 +0530)
committerJoseph Nuthalapati <njoseph@riseup.net>
Sat, 5 Oct 2019 07:12:40 +0000 (12:42 +0530)
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
cli_tube.nim

index d7a3d914efb1623f7ca16de28efe369714eff16f..2c29825d91b3fc421e01662d07188effcba1f7d0 100644 (file)
@@ -13,32 +13,32 @@ import sequtils, sugar
 
 # Supported video players in order of preference
 # TODO Should go into a config file
-let supported_players = @["mpv", "mplayer", "vlc"]
+let supportedPlayers = @["mpv", "mplayer", "vlc"]
 
-proc find_supported_player(): string =
+proc findSupportedPlayer(): string =
   for player in supported_players:
-    let player_bin = execProcess("which " & player)
-    if player_bin.len != 0:
-      return strip(player_bin)
+    let playerBin = execProcess("which " & player)
+    if playerBin.len != 0:
+      return strip(playerBin)
 
-proc get_youtube_page(search_query: string): string =
-  let query_param = encodeUrl(search_query)
+proc getYoutubePage(searchQuery: string): string =
+  let queryParam = encodeUrl(searchQuery)
   var client = newHttpClient()
-  let response = get(client, "https://www.youtube.com/results?hl=en&search_query=" & query_param)
+  let response = get(client, "https://www.youtube.com/results?hl=en&search_query=" & queryParam)
   # TODO Get rid of temp file or make one temp file per user
   writeFile("/tmp/cli-tube-page.html", response.body)
   return "/tmp/cli-tube-page.html"
 
-proc extract_titles_and_urls(html_file: string): seq[tuple[title: string, url: string]] =
-  loadHtml(html_file).findAll("a").
+proc extractTitlesAndUrls(htmlFile: string): seq[tuple[title: string, url: string]] =
+  loadHtml(htmlFile).findAll("a").
     filter(a => "watch" in a.attrs["href"] and a.attrs.hasKey "title").
     map(a => (a.attrs["title"], "https://www.youtube.com" & a.attrs["href"]))
 
-proc present_video_options(titles_and_urls: seq[tuple[title: string, url: string]]) =
-  for number, (title, url) in titles_and_urls:
+proc presentVideoOptions(titlesAndUrls: seq[tuple[title: string, url: string]]) =
+  for number, (title, url) in titlesAndUrls:
     echo number, ". ", title, "\n", url, "\n"
 
-present_video_options(
-  extract_titles_and_urls(
-    get_youtube_page(
+presentVideoOptions(
+  extractTitlesAndUrls(
+    getYoutubePage(
       paramStr(1))))