Added the cli echo viewer and rudimentary README

This commit is contained in:
Luxferre
2024-10-21 22:10:54 +03:00
parent c026d35753
commit 8981e6cfc8
3 changed files with 313 additions and 6 deletions
+32 -6
View File
@@ -1,13 +1,12 @@
#!/usr/bin/env tclsh
# tiifetch: fetch all data from an ii/idec station into the local text db
# (see https://github.com/idec-net/new-docs/blob/master/protocol-en.md)
# Usage: tiifetch station_http_url [echos] [db_dir]
# Usage: tiifetch.tcl [station_url] [echos] [db_dir]
# The echo list should be delimited with slash (/), comma (,) or semicolon (;)
# if no echos are specified (or "" is passed), then list.txt will be fetched
# and then all missing echo content from it will be downloaded
# If db_dir isn't specified, it's fetched and merged into the
# tiidb directory in the program root
# with echoconfs and messages respectively
# tiidb directory in the program root with echoconfs and messages respectively
# This component only fetches the messages, doesn't parse or display them
# Supported protocols: HTTP, HTTPS, Gemini, Spartan, Gopher/Finger/Nex
# Depends on Tcllib for URI parsing
@@ -268,6 +267,24 @@ proc fetchiidb {url echos dbdir dolog} {
}
}
proc massfetch {echos dbdir dolog} {
global appdir
if {$dolog eq 1} {puts "No ii/idec station URL specified, using stations.txt"}
set stfile [file join $appdir "stations.txt"]
if {[file exists $stfile]} {
set stlist [split [readfile $stfile] "\n"]
foreach station $stlist {
set station [string trim $station]
if {$station ne ""} {
if {$dolog eq 1} {puts "Fetching from $station"}
fetchiidb $station $echos $dbdir $dolog
}
}
} else {
if {$dolog eq 1} {puts "No stations.txt found, bailing out!"}
}
}
# end of procs, start the entrypoint
if {![info exists argv0] || [file tail [info script]] ne [file tail $argv0]} {return}
@@ -278,13 +295,22 @@ if [string match *app-tiifetch $appdir] {
set appdir [file normalize [file join $appdir ".." ".." ".." ]]
}
set localdbdir [file join $appdir "tiidb"]
if {$argc > 0} {
set localdbdir [file join $appdir "tiidb"]
if {$argc > 2} {
set localdbdir [lindex $argv 2]
}
puts "Fetching messages, please wait..."
fetchiidb [lindex $argv 0] [lindex $argv 1] $localdbdir 1
set sturl [string trim [lindex $argv 0]]
if {$sturl eq ""} {
massfetch [lindex $argv 1] $localdbdir 1
} else {
fetchiidb $sturl [lindex $argv 1] $localdbdir 1
}
puts "Messages fetched"
} else {puts "No ii/idec station URL specified!"}
} else {
puts "Fetching messages, please wait..."
massfetch "" $localdbdir 1
puts "Messages fetched"
}