From d1b312b83f474fe093d6b7808518aa3249750d92 Mon Sep 17 00:00:00 2001 From: Xerbo Date: Thu, 21 Jul 2022 12:05:10 +0100 Subject: [PATCH] Build bookmarks for SDR++, SDR# and GQRX --- .github/workflows/build.yml | 14 +++++++++++++ .gitignore | 4 ++++ gqrx_bookmarks.py | 14 +++++++++++++ sdrpp_bookmarks.py | 22 +++++++++++++++++++ sdrsharp_bookmarks.py | 42 +++++++++++++++++++++++++++++++++++++ 5 files changed, 96 insertions(+) create mode 100644 gqrx_bookmarks.py create mode 100644 sdrpp_bookmarks.py create mode 100644 sdrsharp_bookmarks.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index afe8682..4f218cd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,6 +15,20 @@ jobs: - name: Build satfreq.json run: rm .gitignore && python3 concatenate.py + - name: Build bookmark files + run: | + python3 sdrpp_bookmarks.py && + python3 sdrsharp_bookmarks.py && + python3 gqrx_bookmarks.py && + mkdir bookmarks && + mv sdrpp_bookmarks.json sdrsharp_bookmarks.xml gqrx_bookmarks.csv bookmarks + + - name: Upload bookmarks + uses: actions/upload-artifact@v3 + with: + name: bookmarks + path: bookmarks/ + - name: Upload satfreq.json uses: actions/upload-artifact@v3 with: diff --git a/.gitignore b/.gitignore index bc205f8..846ce1a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ satfreq.json json/index.html +sdrpp_bookmarks.json +sdrsharp_bookmarks.xml +gqrx_bookmarks.csv +bookmarks/ diff --git a/gqrx_bookmarks.py b/gqrx_bookmarks.py new file mode 100644 index 0000000..21dc26c --- /dev/null +++ b/gqrx_bookmarks.py @@ -0,0 +1,14 @@ +import os +import json + +csv_out = "satfreq; #58A6FF" + os.linesep + os.linesep + +with open("satfreq.json", "r") as sat_file: + sat_json = json.load(sat_file) + for sat in sat_json: + for downlink in sat["downlinks"]: + name = sat["name"] + " " + downlink["name"] + csv_out += str(downlink["frequency"]) + "; " + name + "; Demod Off; 0; satfreq" + os.linesep + +with open("gqrx_bookmarks.csv", "w") as output_file: + output_file.write(csv_out) diff --git a/sdrpp_bookmarks.py b/sdrpp_bookmarks.py new file mode 100644 index 0000000..6cb93ee --- /dev/null +++ b/sdrpp_bookmarks.py @@ -0,0 +1,22 @@ +import json + +bookmarks_json = { + "bookmarkDisplayMode": 1, + "lists": { + "satfreq": { + "bookmarks": {}, + "showOnWaterfall": True + } + }, + "selectedList": "satfreq" +} + +with open("satfreq.json", "r") as sat_file: + sat_json = json.load(sat_file) + for sat in sat_json: + for downlink in sat["downlinks"]: + name = sat["name"] + " " + downlink["name"] + bookmarks_json["lists"]["satfreq"]["bookmarks"][name] = { "bandwidth": 0, "frequency": downlink["frequency"], "mode": 7 } + +with open("sdrpp_bookmarks.json", "w") as output_file: + output_file.write(json.dumps(bookmarks_json, indent=4)) diff --git a/sdrsharp_bookmarks.py b/sdrsharp_bookmarks.py new file mode 100644 index 0000000..fcd8554 --- /dev/null +++ b/sdrsharp_bookmarks.py @@ -0,0 +1,42 @@ +import os +import json +import xml.dom.minidom as minidom + +root = minidom.Document() +xml = root.createElement("ArrayOfMemoryEntry") +xml.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance") +xml.setAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema") + +with open("satfreq.json", "r") as sat_file: + sat_json = json.load(sat_file) + for sat in sat_json: + for downlink in sat["downlinks"]: + bookmark = root.createElement("MemoryEntry") + + val = root.createElement("IsFavourite") + val.appendChild(root.createTextNode("false")) + bookmark.appendChild(val) + val = root.createElement("Name") + val.appendChild(root.createTextNode(sat["name"] + " " + downlink["name"])) + bookmark.appendChild(val) + val = root.createElement("GroupName") + val.appendChild(root.createTextNode("satfreq")) + bookmark.appendChild(val) + val = root.createElement("Frequency") + val.appendChild(root.createTextNode(str(downlink["frequency"]))) + bookmark.appendChild(val) + val = root.createElement("DetectorType") + val.appendChild(root.createTextNode("RAW")) + bookmark.appendChild(val) + val = root.createElement("Shift") + val.appendChild(root.createTextNode("0")) + bookmark.appendChild(val) + val = root.createElement("FilterBandwidth") + val.appendChild(root.createTextNode("0")) + bookmark.appendChild(val) + + xml.appendChild(bookmark) + +with open("sdrsharp_bookmarks.xml", "w") as output_file: + output_file.write("" + os.linesep) + output_file.write(xml.toprettyxml())