Two additions, both about turning a number into something meaningful. A band column. Next to every frequency -- on the live display, in the line-per-hit output, in saunterbrowse's list and details -- is the name of the band it falls in. 421 MHz is the 70 cm amateur band, and being told so is quicker than remembering where the edges are. The names come from the existing preset table, so there is one band plan to keep right rather than two, but naming is not the job that table was shaped for: several presets cover any frequency, some of them whole-tuner sweeps that say nothing. So the candidates are ranked. Sweeps and the "-complete" duplicates are dropped outright. The narrowest of what is left wins, because it says the most -- 146.52 MHz comes back as the 2 m simplex calling channel rather than as the whole 2 m band. Two exceptions where the narrowest would be the wrong answer: ISM yields to the allocation it shares (433.92 is 70 cm first, 915 is 33 cm first), and shortwave broadcast yields to amateur where the two overlap, because 3.9-4.0 and 7.2-7.3 MHz are Region 1 and 3 broadcast but Region 2 amateur, and this plan is documented as Region 2. 6 MHz really is 49 m shortwave and is left alone. The name is written into each capture's sidecar, so it travels with the recording and an edit to the plan later cannot rewrite history, and saunterbrowse searches on it: /70 cm finds the band without anyone having to remember 420-450 MHz. A map. A licence says where its holder is, so a list of callsigns is also a map. Callsigns heard during a scan are now looked up as the transcripts come in, announced on the display, and written to callsigns.kml in the output directory; saunterbrowse --kml builds the same file from recordings already on disk, and the two continue one map rather than starting two. One placemark per station, not one per transmission: the same repeater heard twenty times in an evening is one operator, and twenty pins on one rooftop would say less than one. Each pin carries the callsign, the licensee, the town, the grid square, and every frequency and time it was heard on. The file is read back on open and added to, so later scans build it up rather than replacing it. Where a licence has no coordinates the grid square's centre is used and the placemark says so -- a square is kilometres across where an address is a street. A callsign with no licence at all is still recorded, in a folder that starts switched off, because that a station was heard is worth keeping even when nothing says where. A file already there that is not readable as KML is never overwritten. Also fixed along the way: - The hit list's "no signals recorded yet" placeholder was one cell short of its row, so it landed in the SNR column and wrapped, making the panel taller than the layout had budgeted for and scrolling the display off a short terminal. The identification column can no longer wrap either, which is what _hit_capacity has always assumed. - Licence lookups now record coordinates. The cache is versioned so that entries written before this are asked about again, rather than pinning every station to its grid square for good. - CallsignBook.wait dropped joined threads; an all-night scan calls it after every transcript and the list only ever grew. - Tests redirect XDG_CACHE_HOME, so a run no longer reads or writes the real lookup cache. 676 -> 761 tests.
327 lines
10 KiB
Python
Executable file
327 lines
10 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
"""Generate the saunterbrowse manual page.
|
|
|
|
Hand-written rather than generated from a table: unlike the scanner, the
|
|
browser's surface is a dozen keys and five flags, and describing those is
|
|
prose, not a listing. The version and date still come from the program, so
|
|
the page cannot claim to document a release that was never built.
|
|
"""
|
|
import sys
|
|
from datetime import date
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
|
|
|
import bandsaunter # noqa: E402
|
|
from bandsaunter.browse import PLAYERS, SORTS # noqa: E402
|
|
|
|
|
|
PAGE = r'''.\" Generated by packaging/make-browse-man.py -- do not edit by hand.
|
|
.TH SAUNTERBROWSE 1 "{date}" "bandsaunter {version}" "User Commands"
|
|
.SH NAME
|
|
saunterbrowse \- read and listen to what a bandsaunter scan collected
|
|
.SH SYNOPSIS
|
|
.B saunterbrowse
|
|
.RI [ DIRECTORY ]
|
|
.RB [ \-\-sort
|
|
.IR ORDER ]
|
|
.RB [ \-\-filter
|
|
.IR TEXT ]
|
|
.RB [ \-\-player
|
|
.IR CMD ]
|
|
.RB [ \-\-list ]
|
|
.RB [ \-\-callsigns ]
|
|
.RB [ \-\-kml
|
|
.RI [ FILE ]]
|
|
.RB [ \-\-no\-lookup ]
|
|
.SH DESCRIPTION
|
|
A scan leaves a directory of recordings. Beside each one is a JSON file
|
|
holding what the classifier made of it, and for speech a transcript of what
|
|
was said. Reading that by hand means opening files one at a time and guessing
|
|
which are worth playing.
|
|
.PP
|
|
.B saunterbrowse
|
|
shows them as a list you move through with the arrow keys. The transcript of
|
|
whichever recording is highlighted fills the top of the screen, because that
|
|
is the part you actually want to read; underneath it are the identification,
|
|
the bands the frequency falls in, and the list itself. Pressing Enter plays
|
|
the recording.
|
|
.PP
|
|
With no
|
|
.I DIRECTORY
|
|
it opens the one the scanner writes to, taken from your saved settings, so it
|
|
normally needs no arguments at all.
|
|
.PP
|
|
It only ever reads. Nothing in the recordings directory is renamed, moved or
|
|
deleted.
|
|
.SH KEYS
|
|
.TP
|
|
.B "Up Down k j"
|
|
Move through the recordings.
|
|
.TP
|
|
.B "PgUp PgDn"
|
|
A screenful at a time.
|
|
.TP
|
|
.B "Home End"
|
|
The first and the last.
|
|
.TP
|
|
.B Enter
|
|
Play the highlighted recording. Playing a second one stops the first: two
|
|
players talking over each other is worse than either alone.
|
|
.TP
|
|
.B Space
|
|
Stop playing. With nothing playing, it starts, like Enter.
|
|
.TP
|
|
.B t
|
|
Read the whole transcript full screen, scrolling with the arrow keys. Useful
|
|
for a long net, where the panel at the top can only show the first few lines
|
|
\[em] it says so when there is more.
|
|
.TP
|
|
.B /
|
|
Filter. What you type is matched against the frequency, the filename, the
|
|
identification and
|
|
.I everything that was said,
|
|
so "was the repeater mentioned" is a question you can ask directly. Enter
|
|
accepts, Escape clears.
|
|
.TP
|
|
.B s
|
|
Cycle the order: {sorts}.
|
|
.TP
|
|
.B r
|
|
Re-read the directory. A scan running in another window is still writing to
|
|
it, and this picks up what has arrived since.
|
|
.TP
|
|
.B o
|
|
Print the highlighted recording's path and quit, for piping into something
|
|
else.
|
|
.TP
|
|
.B "? h"
|
|
The list of keys, and which audio player was found.
|
|
.TP
|
|
.B q
|
|
Quit. With a filter in force, Escape clears the filter first.
|
|
.SH OPTIONS
|
|
.TP
|
|
.BI DIRECTORY
|
|
Where the recordings are. Defaults to the scanner's output directory, or to
|
|
.B $BANDSAUNTER_OUTPUT
|
|
when that is set.
|
|
.TP
|
|
.BI \-\-sort " ORDER"
|
|
Start in this order: {sorts}. Time is newest first; duration is longest
|
|
first.
|
|
.TP
|
|
.BI \-\-filter " TEXT"
|
|
Start with only the recordings matching this, exactly as if it had been typed
|
|
at the
|
|
.B /
|
|
prompt.
|
|
.TP
|
|
.BI \-\-player " CMD"
|
|
The command used to play a recording. The path is appended as its last
|
|
argument. By default the first of these that is installed is used:
|
|
{players}.
|
|
.TP
|
|
.B \-\-callsigns
|
|
Print every callsign heard in the directory, with the licence it belongs to
|
|
and where and when it was heard, then exit.
|
|
.TP
|
|
.BI \-\-kml " [FILE]"
|
|
Write a map of where the stations heard in this directory are licensed, and
|
|
exit. Without a filename it writes
|
|
.I callsigns.kml
|
|
in the recordings directory \[em] the same file a scan writes, so a map built
|
|
this way is continued by the next scan rather than duplicated. See
|
|
.B THE MAP
|
|
below.
|
|
.TP
|
|
.B \-\-no\-lookup
|
|
Do not contact the licence database. Callsigns are still found and still
|
|
described from their prefix; only the name and address are missing.
|
|
.TP
|
|
.B \-\-list
|
|
Print one line per recording and exit, without drawing anything. This is what
|
|
to use over a pipe, in a script, or anywhere there is no terminal.
|
|
.TP
|
|
.B \-V ", " \-\-version
|
|
Print the version and exit.
|
|
.SH SOUND
|
|
Playback is handed to whichever player is installed rather than done in the
|
|
program: the recordings are ordinary WAV files, every desktop already has
|
|
something that plays them, and a browser that cannot start is worse than one
|
|
that cannot play. If none is found, everything else still works and the
|
|
message says which packages would fix it.
|
|
.PP
|
|
Over ssh there is usually no sound server at the far end. The browser and its
|
|
transcripts work regardless; only Enter has nothing to do.
|
|
.SH DETECTED CALLSIGNS
|
|
Under the transcript, headed
|
|
.BR "DETECTED CALLSIGNS:" ,
|
|
is every callsign heard in it, with the name and location on the licence.
|
|
.PP
|
|
Finding them is not a matter of one regular expression over the text as
|
|
written. A speech recogniser is poor at callsigns \[em] they are not words,
|
|
they are said one character at a time \[em] so it breaks them wherever the
|
|
speaker paused and writes the phonetic alphabet down verbatim. "KU 0W",
|
|
"K7 RA" and "kilo uniform zero whiskey" are all one callsign each, and all
|
|
three are read back correctly.
|
|
.PP
|
|
False positives are the thing to avoid: a browser that invents callsigns is
|
|
worse than one that finds none. So a run of words is only accepted when none
|
|
of its parts is an ordinary English word \[em] "or 3. Can you open 4" fits the
|
|
shape once the punctuation is gone, and is not a callsign \[em] while a single
|
|
token said in one breath is trusted, because W1BOY is a perfectly good
|
|
callsign.
|
|
.PP
|
|
The lookup uses the FCC's own licence data, published at callook.info, which
|
|
needs no account and no key. The callsign is the only thing sent, results are
|
|
cached under
|
|
.I ~/.cache/bandsaunter/
|
|
so the same net is looked up once however many nights it is recorded, and a
|
|
lookup never delays the display: the entry says "looking up" and fills itself
|
|
in.
|
|
.PP
|
|
.B \-\-no\-lookup
|
|
contacts nothing at all. Callsigns are still found, and still described from
|
|
their own structure \[em] the prefix is allocated by the ITU and the digit is
|
|
the US licensing district, so a callsign says which country and which region
|
|
it belongs to without any database. Outside the United States that is all
|
|
there is; callook.info holds US licences only.
|
|
.PP
|
|
.B \-\-callsigns
|
|
prints every callsign in the directory, who it belongs to, and each frequency
|
|
and time it was heard on, then exits.
|
|
.PP
|
|
US amateur licence records are public by law, and include the licensee's
|
|
address. That is what is shown.
|
|
.SH THE MAP
|
|
A licence says where its holder is, so a list of callsigns is also a map. The
|
|
scanner writes one as it runs and
|
|
.B \-\-kml
|
|
builds one from recordings already on disk; both write the same file, so
|
|
either can carry on from the other.
|
|
.PP
|
|
Each station is one placemark, not one per transmission: hearing the same
|
|
repeater twenty times in an evening is one station, and twenty pins stacked
|
|
on the same rooftop would say less than one. The pin holds the callsign, the
|
|
licensee, the town, the grid square, and every frequency and time it was
|
|
heard on, so clicking it answers "when did I hear this, and where on the
|
|
dial".
|
|
.PP
|
|
The file is added to rather than replaced. A scan on Tuesday continues the
|
|
map Monday made, which over a few weeks turns into a picture of what your
|
|
aerial can actually reach.
|
|
.PP
|
|
Where the licence carries no coordinates the grid square is used instead, and
|
|
the placemark says so, because a grid square is kilometres across where a
|
|
licensed address is a street. A callsign with no licence on file at all is
|
|
still recorded, in a folder named
|
|
.IR "no location on file" ,
|
|
switched off by default: that a station was heard is worth keeping even when
|
|
nothing says where it was.
|
|
.PP
|
|
KML is the format Google Earth uses.
|
|
.BR qgis (1),
|
|
.BR marble (1)
|
|
and OsmAnd open it too, and it is XML, so a scan interrupted halfway through
|
|
leaves a file that still opens.
|
|
.SH TRANSCRIPTS
|
|
A transcript appears only where a recogniser produced one, which means the
|
|
capture was judged to be speech and
|
|
.B bandsaunter\-transcribe
|
|
was installed at the time. Where there is none, the panel says which of the
|
|
several reasons applies \[em] Morse, data, a bare carrier, or speech that was
|
|
never offered to a recogniser \[em] because those want different things done
|
|
about them.
|
|
.PP
|
|
Two places can hold the text: the JSON sidecar records what was recognised
|
|
during the scan, and the
|
|
.I _transcription.txt
|
|
beside the recording is what a later re\-run wrote. The file wins, being the
|
|
more recent of the two.
|
|
.SH FILES
|
|
.TP
|
|
.I ~/bandsaunter/
|
|
Where recordings are written, unless the saved settings say otherwise.
|
|
.TP
|
|
.IR frequency \-\- date _ time \- modulation .wav
|
|
A recording.
|
|
.TP
|
|
.IR ... .json
|
|
Its measurements and identification.
|
|
.TP
|
|
.IR ... _transcription.txt
|
|
What was said, where a recogniser heard speech.
|
|
.SH ENVIRONMENT
|
|
.TP
|
|
.B BANDSAUNTER_OUTPUT
|
|
The directory to open, overriding the saved settings.
|
|
.SH EXAMPLES
|
|
.PP
|
|
.RS
|
|
.EX
|
|
saunterbrowse
|
|
.EE
|
|
.RE
|
|
.PP
|
|
Open the scanner's output directory.
|
|
.PP
|
|
.RS
|
|
.EX
|
|
saunterbrowse /mnt/recordings \-\-sort frequency
|
|
.EE
|
|
.RE
|
|
.PP
|
|
Browse somewhere else, grouped by channel rather than by time.
|
|
.PP
|
|
.RS
|
|
.EX
|
|
saunterbrowse \-\-list | grep \-i "mile marker"
|
|
.EE
|
|
.RE
|
|
.PP
|
|
Search the transcripts from a script.
|
|
.PP
|
|
.RS
|
|
.EX
|
|
saunterbrowse \-\-callsigns
|
|
.EE
|
|
.RE
|
|
.PP
|
|
Everyone who identified themselves, and where they were heard.
|
|
.PP
|
|
.RS
|
|
.EX
|
|
saunterbrowse \-\-kml ~/heard.kml
|
|
.EE
|
|
.RE
|
|
.PP
|
|
The same thing as a map, to open in Google Earth.
|
|
.SH EXIT STATUS
|
|
0 on a clean exit, 1 when the directory holds no recordings, 2 when it does
|
|
not exist or there is no terminal to draw on.
|
|
.SH SEE ALSO
|
|
.BR bandsaunter (1)
|
|
.SH BUGS
|
|
The list is read when the browser opens. Press
|
|
.B r
|
|
to pick up recordings a running scan has written since.
|
|
'''
|
|
|
|
|
|
def main() -> int:
|
|
text = PAGE.format(
|
|
date=date.today().isoformat(),
|
|
version=bandsaunter.__version__,
|
|
sorts=", ".join(SORTS),
|
|
players=", ".join(name for name, _ in PLAYERS))
|
|
text = text.replace("\n\n", "\n") # troff dislikes blank lines
|
|
target = Path(sys.argv[1] if len(sys.argv) > 1
|
|
else Path(__file__).parent / "saunterbrowse.1")
|
|
target.write_text(text)
|
|
print(target)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|