### Install GhettoRecorder via Snap Source: https://github.com/44xtc44/ghettorecorder/blob/dev/README.md Install the GhettoRecorder snap package. After installation, two commands are available: ghettorecorder.url starts the Ghetto HTTP threaded server, and ghettorecorder.cmd opens a command line with a menu. ```shell $ sudo snap install ghettorecorder ``` ```shell $ ghettorecorder.url # Ghetto HTTP threaded server $ ghettorecorder.cmd # command line with menu ``` -------------------------------- ### Import and setup GhettoRecorder Source: https://github.com/44xtc44/ghettorecorder/blob/dev/README.md Shows how to import and configure a GhettoRecorder instance with queues for communication and audio output. The start() method expects a loop in main() to keep the process alive. ```python from ghettorecorder import GhettoRecorder ghetto_raid = GhettoRecorder(radio, url) # use different URLs to test SSL ghetto_raid.com_in = mp.Queue(maxsize=1) # eval exec communication ghetto_raid.com_out = mp.Queue(maxsize=1) # response; exec ok is "None" ghetto_raid.audio_out = mp.Queue(maxsize=1) # current HTTP response buffer ghetto_raid.start() # wants a loop in main() to keep the show alive ``` -------------------------------- ### Install and run GhettoRecorder Source: https://github.com/44xtc44/ghettorecorder/blob/dev/ghettorecorder/index.html Install via pip and run the browser frontend with local HTTP server, or use the command-line interface for terminal options. ```bash pip install ghettorecorder python -m ghettorecorder # browser frontend and local Ghetto HTTP server python -m ghettorecorder.cmd # All options terminal (blacklist, repair, parent folder) ``` -------------------------------- ### Install TypeScript as a dependency Source: https://github.com/44xtc44/ghettorecorder/blob/dev/ghettorecorder/static/ts/setupTS.txt Installs TypeScript as a project dependency using npm. ```bash npm install typescript -s ``` -------------------------------- ### Pip Install Commands Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/README.rst Installation commands for GhettoRecorder. Use pip3 on Linux and pip on Windows. ```text """ Linux """ $ pip3 install ghettorecorder """ Windows """ > pip install ghettorecorder ``` -------------------------------- ### Install and use GhettoRecorder via pip Source: https://github.com/44xtc44/ghettorecorder/blob/dev/README.md Install the Python package with pip3. The package provides command-line and browser interfaces: ghetto_cmd or python3 -m ghettorecorder.cmd for the command line, and ghetto_url or python3 -m ghettorecorder for the browser. ```shell $ pip3 install ghettorecorder ``` ```shell $ pip3 show ghettorecorder # prep removal $ pip3 uninstall ghettorecorder # del custom dirs of recorder in ... /python3.x/site-packages ``` ```shell # command line $ ghetto_cmd # Python executable 'beside' /python3.x/site-packages in /python3.x/Scripts $ python3 -m ghettorecorder.cmd ``` ```shell # browser $ ghetto_url or $ python3 -m ghettorecorder ``` -------------------------------- ### ghettorecorder.ghetto_header_mp3.main(path_str=None) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Example function to get the bitrate. Accepts a file path or object and demonstrates usage. ```APIDOC ## main(path_str=None) ### Description Example to get the bitrate. ### Parameters - **path_str** - file path or object ``` -------------------------------- ### GhettoRecorder class module example Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/README.rst Shows how to instantiate the GhettoRecorder class with a radio and URL, and set up multiprocessing queues for communication and audio output. ```python from ghettorecorder import GhettoRecorder ghetto_01 = GhettoRecorder(radio, url) ghetto_01.com_in = mp.Queue(maxsize=1) # eval exec communication for multiprocessing ghetto_01.audio_out = mp.Queue(maxsize=1) # can also be normal queue.Queue() ``` -------------------------------- ### pull_first_frame(path_str=None) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Get first header dict. ```APIDOC ## pull_first_frame(path_str=None) ### Description Get first header dict. ### Method Function call ### Endpoint `ghettorecorder.ghetto_header_aac.pull_first_frame(path_str=None)` ### Parameters - **path_str** (optional) - Optional - File path or object. ``` -------------------------------- ### Initialize tsconfig.json with defaults Source: https://github.com/44xtc44/ghettorecorder/blob/dev/ghettorecorder/static/ts/setupTS.txt Creates the tsconfig.json file with 100 options. Run this in the terminal folder containing the TypeScript files. ```bash npm run tsc -- --init ``` -------------------------------- ### GhettoRecorder.radio_grab() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Gets connection. Feeds listen queue and recorder file on file system. ```APIDOC ## GhettoRecorder.radio_grab() ### Description Gets connection. Feeds listen queue and recorder file on file system. ### Parameters None ### Returns None ``` -------------------------------- ### ghettorecorder.ghetto_net.load_url(url, user_agent=None) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Get server response. The place of hope and 'interesting behaviour'. ```APIDOC ## ghettorecorder.ghetto_net.load_url(url, user_agent=None) ### Description Get server response. The place of hope and 'interesting behaviour'. ### Parameters - **url** - Required - url - **user_agent** - Optional - user agent string ### Returns - **http server response** (http response) ### Exceptions - Timeout recursive call ``` -------------------------------- ### radio_instance_create(radio, url, **kwargs) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Starts a radio instance if it does not already exist. This function creates a new radio instance with the specified URL and configuration, attaching message queues for communication. ```APIDOC ## radio_instance_create(radio, url, **kwargs) ### Description Starts a radio instance if it does not already exist. This function creates a new radio instance with the specified URL and configuration, attaching message queues for communication. ### Parameters - **radio** (string) - Required - Name of the radio instance. - **url** (string) - Required - URL of the radio stream. - **kwargs** - Optional - Additional keyword arguments including: - **com_in** (mp.Queue) - Optional - Input control queue (maxsize=1) for sending commands. - **com_out** (mp.Queue) - Optional - Output control queue (maxsize=1) for receiving results. - **audio_out** (mp.Queue) - Optional - Queue for audio data output. - **config** - Optional - Configuration settings. - **blacklist** - Optional - Blacklist settings. - **path variables** - Optional - Path variables. ### Returns True if the instance was created or is already running. ``` -------------------------------- ### Compile TypeScript Source: https://github.com/44xtc44/ghettorecorder/blob/dev/ghettorecorder/static/ts/setupTS.txt Compiles the TypeScript files according to the tsconfig.json configuration. ```bash npm run tsc ``` -------------------------------- ### ghettorecorder.ghetto_net.content_type_get(response) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Get Content-Type of response. Bugfix for Chrome browsers. ```APIDOC ## ghettorecorder.ghetto_net.content_type_get(response) ### Description Content-Type of response. Bugfix for Chrome browsers. ### Parameters - **response** - Required - http response ### Returns - **Content-Type** (str) ``` -------------------------------- ### GhettoRecorder.user_agent_get() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/modules.rst Gets the user agent. This method is part of the GhettoRecorder class. ```APIDOC ## GhettoRecorder.user_agent_get() ### Description Gets the user agent. ### Method Method ### Signature `GhettoRecorder.user_agent_get()` ### Parameters No parameters documented. ### Returns No return value documented. ``` -------------------------------- ### read_all_header(aac_object) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Example function returns all frame content with header until empty. Returns an iterator of dicts. ```APIDOC ## read_all_header(aac_object) ### Description Example function returns all frame content with header until empty. Returns an iterator of dicts. ### Method Function call ### Endpoint `ghettorecorder.ghetto_header_aac.read_all_header(aac_object)` ### Parameters - **aac_object** (bytes) - Required - Bytes type object. ### Returns - **Iterator[dict]** - Header information and object content. ``` -------------------------------- ### pull_frames(path_str=None) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Get last header dict. Can get frame count to calc bitrate. ```APIDOC ## pull_frames(path_str=None) ### Description Get last header dict. Can get frame count to calc bitrate. ### Method Function call ### Endpoint `ghettorecorder.ghetto_header_aac.pull_frames(path_str=None)` ### Parameters - **path_str** (optional) - Optional - File path or object. ### Returns - **dict** - Header dict of last frame; can get frame count to calc bitrate. ``` -------------------------------- ### GhettoRecorder.start_worker_threads() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/modules.rst Starts worker threads. This method is part of the GhettoRecorder class. ```APIDOC ## GhettoRecorder.start_worker_threads() ### Description Starts worker threads. ### Method Method ### Signature `GhettoRecorder.start_worker_threads()` ### Parameters No parameters documented. ### Returns No return value documented. ``` -------------------------------- ### Record Menu with Radio List Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/README.rst Shows the record menu listing available radio stations. Enter the list index or radio name to select, add multiple radios, and press Enter without input to start recording. Listen to the first selected radio via local streaming at http://localhost:1242/. ```text 0 >> aacchill << 1 >> 80ies_nl << 2 >> anime_jp << 3 >> blues_uk << 4 >> br24 << ... Enter to record -->: ``` -------------------------------- ### Run JavaScript without a browser using Node.js Source: https://github.com/44xtc44/ghettorecorder/blob/dev/ghettorecorder/static/ts/setupTS.txt Runs the compiled JavaScript file directly with Node.js, useful for testing without a browser. This is not the intended workflow for this migration. ```bash node build/app.js ``` -------------------------------- ### ghettorecorder.ghetto_net.pls_m3u_resolve_url(url) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Return URL, if input url was a play list. Example: 'http://metafiles.gl-systemhaus.de/hr/hr3_2.m3u' to 'http://dispatcher.rndfnk.com/hr/hr3/live/mp3/128/stream.mp3'. ```APIDOC ## ghettorecorder.ghetto_net.pls_m3u_resolve_url(url) ### Description Return URL, if input url was a play list. Example: 'http://metafiles.gl-systemhaus.de/hr/hr3_2.m3u' to 'http://dispatcher.rndfnk.com/hr/hr3/live/mp3/128/stream.mp3'. ### Parameters - **url** - Required - url ### Returns - **true url of server or does nothing** (str) ``` -------------------------------- ### header_info(aac_object, frame_bytes=None, print_out=None) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Caller can name a slice of the object `aac_object[start idx:]` to work. Returns frame header properties as a dict. ```APIDOC ## header_info(aac_object, frame_bytes=None, print_out=None) ### Description Caller can name a slice of the object `aac_object[start idx:]` to work. Returns frame header properties as a dict. ### Method Function call ### Endpoint `ghettorecorder.ghetto_header_aac.header_info(aac_object, frame_bytes=None, print_out=None)` ### Parameters - **aac_object** (full object or slice) - Required - Full object or slice to process. - **frame_bytes** (optional) - Optional - Dump whole frame to header_dict['FRAME_BYTES']. - **print_out** (optional) - Optional - Enable print to screen. ### Returns - **dict** - Frame header properties. ``` -------------------------------- ### parent_record_path_get() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Returns the custom path used as parent dir from ini. For example, save_to_dir = storageemulated0Music. ```APIDOC ## parent_record_path_get() ### Description Returns the custom path used as parent dir from ini. For example, save_to_dir = storageemulated0Music. ### Method Function call ### Parameters None ### Returns - **str** - The custom parent directory path from ini. ``` -------------------------------- ### GhettoRecorder.radio_metadata_get() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/modules.rst Gets radio metadata. This method is part of the GhettoRecorder class. ```APIDOC ## GhettoRecorder.radio_metadata_get() ### Description Gets radio metadata. ### Method Method ### Signature `GhettoRecorder.radio_metadata_get()` ### Parameters No parameters documented. ### Returns No return value documented. ``` -------------------------------- ### bin_writer_reset_file_offset(bin_writer) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Resets the file writer offset to the beginning of the file. This is used to prepare the recorder file for writing from the start. ```APIDOC ## bin_writer_reset_file_offset(bin_writer) ### Description Reset file writer offset to begin of file. ### Parameters - **bin_writer**: instance of the open recorder file ``` -------------------------------- ### GhettoRecorder.evaluate_response_header() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Scans data stream for mp3 and aac bit rates. Falls back to header information on error. Gets size of buffer to calculate chunk size for writing to fs and listen queue. ```APIDOC ## GhettoRecorder.evaluate_response_header() ### Description Scans data stream for mp3 and aac bit rates. Falls back to header information on error. Gets size of buffer to calculate chunk size for writing to fs and listen queue. ### Parameters None ### Returns - **bool** - True on success; None on error, Main can read error_dict and cancel the thread. ### Exceptions - File extension of stream not available, keep instance running for error evaluation. ``` -------------------------------- ### bit_rate_get(aac_object) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Get bitrate for a chunk or file. Accepts a file name or file stream and returns the bitrate as a float. ```APIDOC ## bit_rate_get(aac_object) ### Description Get bitrate for a chunk or file. Accepts a file name or file stream and returns the bitrate as a float. ### Method Function call ### Endpoint `ghettorecorder.ghetto_header_aac.bit_rate_get(aac_object)` ### Parameters - **aac_object** (file name or file stream) - Required - File name or file stream to calculate bitrate. ### Returns - **bitrate** (float) - The calculated bitrate. ``` -------------------------------- ### ghettorecorder.ghetto_net.stream_filetype_url(response, str_radio) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Get file suffix of the stream from content-type. Not called if the server failed before. ```APIDOC ## ghettorecorder.ghetto_net.stream_filetype_url(response, str_radio) ### Description Get file suffix of the stream from content-type. Not called if the server failed before. ### Parameters - **response** - Required - http response - **str_radio** - Required - name ### Returns - **stream suffix** (str) ``` -------------------------------- ### header_index_get(aac_object) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Scan the file object for an aac frame. Search frame is hex. Returns the index number of the first frame start byte in the stream. ```APIDOC ## header_index_get(aac_object) ### Description Scan the file object for an aac frame. Search frame is hex. Returns the index number of the first frame start byte in the stream. ### Method Function call ### Endpoint `ghettorecorder.ghetto_header_aac.header_index_get(aac_object)` ### Parameters - **aac_object** (bytes) - Required - The bytes object to scan. ### Returns - **int** - Index number of the first frame start byte in the stream. ``` -------------------------------- ### Add tsc script to package.json Source: https://github.com/44xtc44/ghettorecorder/blob/dev/ghettorecorder/static/ts/setupTS.txt Adds the "tsc" script to the "scripts" section of package.json so you can run TypeScript commands via npm. Place it in the root of the package. ```json "scripts": { "tsc": "tsc" } ``` -------------------------------- ### ghettorecorder.ghetto_net.bit_rate_get(chunk, suffix) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Get bitrate from stream to adapt buffer size for writing and listen queue. Raises an exception if the stream is not mp3 or aac or has wrong content-type. ```APIDOC ## ghettorecorder.ghetto_net.bit_rate_get(chunk, suffix) ### Description Get bitrate from stream to adapt buffer size for writing and listen queue. ### Parameters - **chunk** - Required - chunk to scan for bitrate - **suffix** - Required - stream file extension ### Returns - **bit rate value** (int) ### Exceptions - stream is not mp3 or aac; has wrong content-type ``` -------------------------------- ### radio_attribute_get(radio=None, attribute=None) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Evaluates a request to get an attribute value from a radio instance. This function retrieves the value of a specified attribute from the given radio instance. ```APIDOC ## radio_attribute_get(radio=None, attribute=None) ### Description Evaluates a request to get an attribute value from a radio instance. This function retrieves the value of a specified attribute from the given radio instance. ### Parameters - **radio** (string) - Optional - Name of the radio instance. - **attribute** (string) - Optional - Name of the attribute to retrieve. ### Returns The value of the specified attribute. ``` -------------------------------- ### AAC File Repair Output Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/README.rst Shows the repair process for AAC files. Repaired files are stored in an 'aac_repair' subfolder, and the cut bytes count is shown at the end of each line. Repair can fail if the file is corrupted not only at start or end. ```text Write a path to aac files. Only aac files will be touched. ..settings.ini [GLOBAL] section: {'blacklist_enable': 'True', 'save_to_dir': 'f:\\31'} Enter a path, OS syntax (f:\10 or /home ) -->:f:\6aac created: f:\6aac f:\6aac\aac_repair created [ COPY(s) in f:\6aac\aac_repair ] ----- 1 file(s) failed ----- f:\6aac\Sergey Sirotin & Golden Light Orchestra - Around The World.aacp ValueError non-hexadecimal number found in fromhex() arg at position 5438113 ----- 97 file(s) repaired ----- f:\6aac\111_Slovo_Original_Mix.aac; cut(bytes): [330] f:\6aac\351 Lake Shore Drive - You Make My Day.aacp; cut(bytes): [389] ``` -------------------------------- ### container_setup() -> str Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Sets up a container environment by copying settings.ini to the container writable user folder. Returns the folder path where settings.ini and blacklist.json reside, or an empty string if no package-specific environment variable is set. ```APIDOC ## container_setup() -> str ### Description Sets up a container environment. Copies settings.ini to the container writable user folder. Returns the folder path where settings.ini and blacklist.json reside, or an empty string if no package-specific environment variable is set. ### Method Function call ### Parameters None ### Returns - **str** - Folder path where settings.ini and blacklist.json reside, or empty string if no package-specific environment variable is set. ``` -------------------------------- ### Client Server option (calls __main__.py) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/README.rst Run GhettoRecorder as a client-server application using the ghetto_url command or by invoking the module directly. ```bash ghetto_url or python3 -m ghettorecorder ``` -------------------------------- ### GhettoRecorder.__init__(name, url) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Initializes a GhettoRecorder instance with a custom alias and a URL or playlist deployment server. The URL can be resolved via resolve_playlist_url(). ```APIDOC ## GhettoRecorder.__init__(name, url) ### Description Initializes a GhettoRecorder instance with a custom alias and a URL or playlist deployment server. The URL can be resolved via resolve_playlist_url(). ### Parameters - **name** (string) - Required - Custom alias for the internet radio server. - **url** (string) - Required - URL or playlist deployment server; see resolve_playlist_url(). ### Returns None ``` -------------------------------- ### Main Menu Options Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/README.rst Displays the main menu with options for recording, changing paths, toggling blacklists, setting config path, repairing AAC files, and exiting. ```text menu 'Main' 1 -- Record (local listen option) 2 -- Change parent record path 3 -- Enable/disable blacklists 4 -- Set path to config, settings.ini 5 -- aac file repair 6 -- Exit ``` -------------------------------- ### ghettorecorder.main(radio='nachtflug', url='http://85.195.88.149:11810') Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Not executed if imported as module, but can be called explicitly. ```APIDOC ## ghettorecorder.main(radio='nachtflug', url='http://85.195.88.149:11810') ### Description Not executed if imported as module, but can be called explicitly. ### Parameters - **radio** (string) - Optional - Radio name. Default: 'nachtflug'. - **url** (string) - Optional - URL of the radio stream. Default: 'http://85.195.88.149:11810'. ### Returns None ``` -------------------------------- ### main() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/modules.rst Entry point for the ghettorecorder application. This function is part of the ghettorecorder module. ```APIDOC ## main() ### Description Entry point for the ghettorecorder application. ### Method Function ### Signature `main()` ### Parameters No parameters documented. ### Returns No return value documented. ``` -------------------------------- ### make_config_folder(ghetto_folder) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Creates a configuration folder for the container environment. ```APIDOC ## make_config_folder(ghetto_folder) ### Description Creates a configuration folder for the container environment. ### Method Function call ### Parameters - **ghetto_folder** - Required - The folder path to create. ### Returns None (not specified). ``` -------------------------------- ### GhettoRecorder.run() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Spawn Thread –> _instance.start(). run() 'works' in the current (main) thread. It doesn't spawn a new thread. ```APIDOC ## GhettoRecorder.run() ### Description Spawn Thread –> _instance.start(). run() 'works' in the current (main) thread. It doesn't spawn a new thread. ### Parameters None ### Returns None ``` -------------------------------- ### Commandline option (calls cmd.py) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/README.rst Run GhettoRecorder from the command line using the ghetto_cmd command or by invoking the module directly. ```bash ghetto_cmd or python3 -m ghettorecorder.cmd ``` -------------------------------- ### container_copy_settings(**kwargs) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Copies settings.ini to the container writable user folder without overwriting a user customized settings.ini. ```APIDOC ## container_copy_settings(**kwargs) ### Description Copies settings.ini to the container writable user folder. Never overwrites a user customized settings.ini. ### Method Function call ### Parameters - **kwargs** - Optional - Additional keyword arguments (not specified). ### Returns None (not specified). ``` -------------------------------- ### Import GhettoRecorder module Source: https://github.com/44xtc44/ghettorecorder/blob/dev/ghettorecorder/index.html Import the GhettoRecorder class from the ghettorecorder package. ```python from ghettorecorder import GhettoRecorder ``` -------------------------------- ### GhettoRecorder.radio_init() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/modules.rst Initializes the radio. This method is part of the GhettoRecorder class. ```APIDOC ## GhettoRecorder.radio_init() ### Description Initializes the radio. ### Method Method ### Signature `GhettoRecorder.radio_init()` ### Parameters No parameters documented. ### Returns No return value documented. ``` -------------------------------- ### make_dirs() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/modules.rst Creates directories. This function is part of the ghettorecorder.ghetto_utils module. ```APIDOC ## make_dirs() ### Description Creates directories. ### Method Function ### Signature `make_dirs()` ### Parameters No parameters documented. ### Returns No return value documented. ``` -------------------------------- ### get_env_snap() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Retrieves the environment variable for Snap container deployment. ```APIDOC ## get_env_snap() ### Description Retrieves the environment variable for Snap container deployment. ### Method Function call ### Parameters None ### Returns None (not specified). ``` -------------------------------- ### Set Path to Config Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/README.rst Prompts for a new path to store settings.ini and blacklist.json. The default location for grabbed files is the mentioned folder, but a custom save path written to config overrides it. ```text Write Path to settings.ini and blacklist.json file Enter a new path, OS syntax (f:\10 or /home ) -->: F:\44 created: F:\44 ..settings.ini [GLOBAL] section: {'blacklist_enable': 'True'} Hit Enter to leave -->: ``` -------------------------------- ### create_config_env(ghetto_folder) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Copies config files outside the default package folder /site-settings/ghettorecorder. Creates a new parent record folder, overwrites radio_base_dir default path, and copies settings.ini to that folder. ```APIDOC ## create_config_env(ghetto_folder) ### Description Copies config files outside the default package folder /site-settings/ghettorecorder. Creates a new parent record folder, overwrites radio_base_dir default path, and copies settings.ini to that folder. ### Method Function call ### Parameters - **ghetto_folder** - Required - The folder path where config files should be copied. ### Returns None (not specified). ``` -------------------------------- ### ghettorecorder.ghetto_net.playlist_m3u(url) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst We know it is a playlist. Return the first server. ```APIDOC ## ghettorecorder.ghetto_net.playlist_m3u(url) ### Description We know it is a playlist. Return the first server. ### Parameters - **url** - Required - url ### Returns - **true url of server** (str) ### Exceptions - server not ready ``` -------------------------------- ### path_title_cut(str_radio, rec_dst) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst No description provided. ```APIDOC ## path_title_cut(str_radio, rec_dst) ### Description No description provided. ### Parameters - **str_radio**: (not documented) - **rec_dst**: (not documented) ``` -------------------------------- ### Uninstall Commands Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/README.rst Commands to show module location and uninstall GhettoRecorder. After uninstalling, remove remnants from the site-packages directory. ```text >$ pip3 show ghettorecorder >$ pip3 uninstall ghettorecorder ``` -------------------------------- ### GhettoRecorder.info_dump_dct_update() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Adds non header info. ```APIDOC ## GhettoRecorder.info_dump_dct_update() ### Description Adds non header info. ### Parameters None ### Returns None ``` -------------------------------- ### Configuration File Settings.ini Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/README.rst Defines radio stations and global settings. The [STATIONS] section maps custom radio names to stream URLs (can be pls or m3u playlists). The [GLOBAL] section stores blacklist status and the custom parent directory location. ```ini [STATIONS] anime_jp = http://streamingv2.shoutcast.com/japanimradio-tokyo [GLOBAL] blacklist_enable = True save_to_dir = f:\54321 ``` -------------------------------- ### radio_instances_get() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Returns a list of running radio instances. This function allows you to connect to the queues for communication with the instances. ```APIDOC ## radio_instances_get() ### Description Returns a list of running radio instances. This function allows you to connect to the queues for communication with the instances. ### Parameters None ### Returns List of running radio instances. ``` -------------------------------- ### GhettoRecorder.run() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/modules.rst Runs the recorder. This method is part of the GhettoRecorder class. ```APIDOC ## GhettoRecorder.run() ### Description Runs the recorder. ### Method Method ### Signature `GhettoRecorder.run()` ### Parameters No parameters documented. ### Returns No return value documented. ``` -------------------------------- ### Mp3Header.bitrate_get() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Searches for the first bits of the MP3 header, finds the sync word, and extracts the bitrate by masking and bit-shifting. Returns the bitrate as an integer, or None if not found. ```APIDOC ## bitrate_get() ### Description Looking for the first bits of mp3 header. Search sync_word. Second byte of word has only 3bit information. Mask and bit-shift. ### Returns - bitrate int, or None ``` -------------------------------- ### GhettoRecorder.radio_db_remote_control_run() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Thread switches features via Database interface; Frontend or DB browser. ```APIDOC ## GhettoRecorder.radio_db_remote_control_run() ### Description Thread switches features via Database interface; Frontend or DB browser. ### Parameters None ### Returns None ``` -------------------------------- ### GhettoRecorder.start_worker_threads() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Meta extracts new titles from metadata requests. It creates file names from title, if title is available. Meta creates the path for the recorder file dump. ```APIDOC ## GhettoRecorder.start_worker_threads() ### Description Meta extracts new titles from metadata requests. It creates file names from title, if title is available. Meta creates the path for the recorder file dump. ### Parameters None ### Returns None ``` -------------------------------- ### GhettoRecorder.build_folders() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/modules.rst Builds the folder structure for the recorder. This method is part of the GhettoRecorder class. ```APIDOC ## GhettoRecorder.build_folders() ### Description Builds the folder structure for the recorder. ### Method Method ### Signature `GhettoRecorder.build_folders()` ### Parameters No parameters documented. ### Returns No return value documented. ``` -------------------------------- ### user_display_dict_get(radio) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Provides a user overview of the radio instance. This function returns information about file locations, header info, and which recorder is running. ```APIDOC ## user_display_dict_get(radio) ### Description Provides a user overview of the radio instance. This function returns information about file locations, header info, and which recorder is running. ### Parameters - **radio** (string) - Required - Name of the radio instance. ### Returns Dictionary containing user display information. ``` -------------------------------- ### record_write_first() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/modules.rst Writes the first part of a recording. This function is part of the ghettorecorder.ghetto_recorder module. ```APIDOC ## record_write_first() ### Description Writes the first part of a recording. ### Method Function ### Signature `record_write_first()` ### Parameters No parameters documented. ### Returns No return value documented. ``` -------------------------------- ### this_time() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Marks a recorded title if no metadata are available. ```APIDOC ## this_time() ### Description Mark a recorded title if no metadata are available. ### Returns - date and time ### Return type - str ``` -------------------------------- ### Blacklist Menu Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/README.rst Menu to toggle blacklist writing. Option 1 enables blacklist (prevents re-recording existing titles), option 2 disables, option 3 returns to Main Menu. Blacklist file is 'blacklist.json' in the same folder as 'settings.ini'. ```text Write a new blacklist option to settings.ini file ..settings.ini [GLOBAL] section: {'blacklist_enable': 'True', 'save_to_dir': 'f:\\31'} 1 -- blacklist on (don't write title if already downloaded) 2 -- blacklist off 3 -- Back to Main Menu Enter your choice: 1 blacklist is ON: settings.ini file Existing titles are not recorded again and again. file name is "blacklist.json" in the same folder as "settings.ini" ..settings.ini [GLOBAL] section: {'blacklist_enable': 'True', 'save_to_dir': 'f:\\31'} Hit Enter to leave -->: ``` -------------------------------- ### ghettorecorder.ghetto_net.suffix_from_content_type_get(content_type) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Translate content-type to file suffix. ```APIDOC ## ghettorecorder.ghetto_net.suffix_from_content_type_get(content_type) ### Description Translate content-type to file suffix. ### Parameters - **content_type** - Required - content_type ### Returns - **stream suffix** (str) ``` -------------------------------- ### render_data() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/modules.rst Renders data. This function is part of the ghettorecorder.ghetto_utils module. ```APIDOC ## render_data() ### Description Renders data. ### Method Function ### Signature `render_data()` ### Parameters No parameters documented. ### Returns No return value documented. ``` -------------------------------- ### parent_record_path_change(folder) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Populates variables in GIni with the new parent record folder path. ```APIDOC ## parent_record_path_change(folder) ### Description Populates variables in GIni with the new parent record folder path. ### Method Function call ### Parameters - **folder** - Required - The new parent record folder path. ### Returns None (not specified). ``` -------------------------------- ### GhettoRecorder.open_recorder_file() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/modules.rst Opens a recorder file. This method is part of the GhettoRecorder class. ```APIDOC ## GhettoRecorder.open_recorder_file() ### Description Opens a recorder file. ### Method Method ### Signature `GhettoRecorder.open_recorder_file()` ### Parameters No parameters documented. ### Returns No return value documented. ``` -------------------------------- ### teardown(str_radio, bin_writer, rec_src, rec_dst) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Performs a graceful copy and marks files incomplete at shut down. ```APIDOC ## teardown(str_radio, bin_writer, rec_src, rec_dst) ### Description Graceful copy, mark files incomplete at shut down. ### Parameters - **str_radio**: radio name - **rec_src**: name of the recorder file in OS syntax, needed in if-clause to copy to physical path - **bin_writer**: alias of with statement for writing to recorder file - **rec_dst**: absolute path to user file ### Exceptions - **OSError**: on disk fail or folder not writeable ``` -------------------------------- ### Mp3Header.mp3_object_to_bytes() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Converts a path to a file-like object if a path is given, otherwise returns the bytes object as is. ```APIDOC ## mp3_object_to_bytes() ### Description Convert path to file like object, if path, else it is bytes object ``` -------------------------------- ### ghettorecorder.ghetto_api.GhettoApi Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Container class exposing useful variables for communication between modules, such as radio instances, measurement data, and configuration paths. ```APIDOC ## GhettoApi ### Description Container class for exposing useful variables to Terminal or Flask. It stores radio instances, measurement data, audio stream queues, and configuration paths. ### Attributes - **radio_inst_dict** (dict) - Stores radio instances: `ghettoApi.radio_inst_dict[radio] = GhR(radio, url)` - **measure_dict** (dict) - Response header values for UI: `{'radio,elem': txt}` - **audio_stream_queue_dict** (dict) - Queue buffer to web server for HTML audio element: `{'radio,audio': queue_data}` - **audio_stream_suffix_dict** (dict) - File extension of audio stream data: `{'radio_name,audio': '.mp3'}` - **audio_stream_content_type_dict** (dict) - Content type for Flask: `{'radio1,audio': 'audio/mpeg', 'radio2,audio': 'audio/aac'}` - **current_title_dict** (dict) - Current song title per radio: `{'radio_name': song_title}` - **error_dict** (dict) - Error messages for web server - **recorder_new_title_dict** (dict) - New title to compare with blacklists - **all_blacklists_dict** (dict) - Stores all blacklists from filesystem or database - **stop_blacklist_writer** (bool) - Stop writer thread - **skipped_in_session_dict** (dict) - Effects of record blacklisting per session - **blacklist_dir** (str) - Path to record blacklist JSON - **blacklist_name** (str) - Name of record blacklist file - **blacklist_enable** (bool) - Enables blacklist for all radios - **config_dir** (str) - Absolute path to ini config file - **config_name** (str) - Name of ini config file - **radio_parent** (str) - Name of radio parent directory (e.g., 'RADIOS') - **save_to_dir** (str) - Full path to save files, overrides default - **radio_err_count_dict** (dict) - Connection error count per radio: `{'radio_name': 42}` - **feature_mgr_dict** (dict) - Feature manager instances ### Subclasses - **Audio** - Base class for audio-related attributes - **BlackList** - Base class for blacklist-related attributes - **Err** - Base class for error-related attributes - **Feature** - Base class for feature-related attributes - **Info** - Base class for info-related attributes - **Path** - Base class for path-related attributes ``` -------------------------------- ### GhettoRecorder.radio_exec_loop() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst TUPLE!!! Can NOT change values. rv_tup = (radio, 'eval' or 'exec', 'command') ```APIDOC ## GhettoRecorder.radio_exec_loop() ### Description TUPLE!!! Can NOT change values. rv_tup = (radio, 'eval' or 'exec', 'command') ### Parameters None ### Returns None ``` -------------------------------- ### Change Parent Record Path Menu Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/README.rst Menu to change the parent directory for recorded files. Option 1 writes a new path to config; option 2 returns to Main Menu. The default path is the module directory, but a custom path is often needed. ```text option 'Change record parent path' 1 -- New parent path for recorded radios. Write to config. 2 -- Back to Main Menu Enter your choice: 1 Write a new path to store files ..settings.ini [GLOBAL] section: {'blacklist_enable': 'True', 'save_to_dir': 'f:\\31'} Enter a new path, OS syntax (f:\10 or /home ) -->: ``` -------------------------------- ### GhettoRecorder.radio_exec_loop_run() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/modules.rst Runs the radio execution loop. This method is part of the GhettoRecorder class. ```APIDOC ## GhettoRecorder.radio_exec_loop_run() ### Description Runs the radio execution loop. ### Method Method ### Signature `GhettoRecorder.radio_exec_loop_run()` ### Parameters No parameters documented. ### Returns No return value documented. ``` -------------------------------- ### radio_control_qs_get(radio) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Retrieves the control queues for a radio instance. This function performs a basic check that the radio instance is available and returns the control queues for communication. ```APIDOC ## radio_control_qs_get(radio) ### Description Retrieves the control queues for a radio instance. This function performs a basic check that the radio instance is available and returns the control queues for communication. ### Parameters - **radio** (string) - Required - Name of the radio instance to connect to. ### Returns Tuple of control queues (input and output). ``` -------------------------------- ### record_write_first(chunk, bin_writer=None, suffix=None) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Returns the first head cleaned aac chunk after a title change, else mp3 dirty chunk. ```APIDOC ## record_write_first(chunk, bin_writer=None, suffix=None) ### Description Return first head cleaned aac chunk after a title change, else mp3 dirty chunk. ### Parameters - **chunk**: part of http response stream - **bin_writer**: instance of the open recorder file - **suffix**: file suffix ``` -------------------------------- ### radio_run_cmd(radio=None, cmd=None) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Runs one or multiple commands as a string in the radio instance. This function executes a Python statement within the specified radio instance. ```APIDOC ## radio_run_cmd(radio=None, cmd=None) ### Description Runs one or multiple commands as a string in the radio instance. This function executes a Python statement within the specified radio instance. ### Parameters - **radio** (string) - Optional - Name of the radio instance. - **cmd** (string) - Optional - Python statement to execute. ### Returns None ``` -------------------------------- ### remove_dst(rec_dst, bin_writer) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Deletes an existing file for shutil copy. ```APIDOC ## remove_dst(rec_dst, bin_writer) ### Description Delete existing file for shutil copy. ### Parameters - **rec_dst**: absolute path to user file - **bin_writer**: instance of the open recorder file ### Return type - True ``` -------------------------------- ### GhettoRecorder.radio_db_remote_control() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Multiprocessor communication via database, no eval or exec. Frontend wants to switch off a feature. Browser -> Server -> DB attribute = False. Dynamically created database table to read properties (attributes not known yet). Static table to switch settings (known attributes). ```APIDOC ## GhettoRecorder.radio_db_remote_control() ### Description Multiprocessor communication via database, no eval or exec. Frontend wants to switch off a feature. Browser -> Server -> DB attribute = False. Dynamically created database table to read properties (attributes not known yet). Static table to switch settings (known attributes). ### Parameters None ### Returns None ``` -------------------------------- ### ghettorecorder.audio_conf.sample_matrix Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Returns the sample rate for a given MPEG version and sample bits. The caller provides an integer value for the sample bits. ```APIDOC ## sample_matrix(mpeg_ver, sample_bits) ### Description Returns the sample rate for the given MPEG version and sample bits. ### Parameters - **mpeg_ver** (int) - Required - MPEG version: 1, 2, or 2.5 - **sample_bits** (int) - Required - Two bits indicating sample rate index ### Returns - **int** - The sample rate for the given arguments - **False** - If not found or reserved ``` -------------------------------- ### write_recorder(chunk, bin_writer) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Writes chunks to the recorder file. Mp3 files are not repaired. Browser plays them. ```APIDOC ## write_recorder(chunk, bin_writer) ### Description Write chunks to the recorder file. Mp3 files are not repaired. Browser plays them. ### Parameters - **chunk**: part of http response stream - **bin_writer**: instance of the open recorder file ### Exceptions - **File already closed**: chunk grabbed before and not written after recorder shutdown ``` -------------------------------- ### convert_ascii() Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/modules.rst Converts a string to ASCII. This function is part of the ghettorecorder.ghetto_utils module. ```APIDOC ## convert_ascii() ### Description Converts a string to ASCII. ### Method Function ### Signature `convert_ascii()` ### Parameters No parameters documented. ### Returns No return value documented. ``` -------------------------------- ### radio_wait_online(radio) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Asks the radio instance for its ready status. This function waits until the instance reports that it is online. ```APIDOC ## radio_wait_online(radio) ### Description Asks the radio instance for its ready status. This function waits until the instance reports that it is online. ### Parameters - **radio** (string) - Required - Name of the radio instance. ### Returns None ``` -------------------------------- ### GhettoRecorder.rec_dump(rec_dst) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Copies recorder file with meta title name to user file. Uses this chunk as end, and beginning for the next user file. Writes last chunk (repair if aac), dump recorder file, reset, write first chunk (repair if aac). ```APIDOC ## GhettoRecorder.rec_dump(rec_dst) ### Description Copies recorder file with meta title name to user file. Uses this chunk as end, and beginning for the next user file. Writes last chunk (repair if aac), dump recorder file, reset, write first chunk (repair if aac). ### Parameters - **rec_dst** (string) - Required - Absolute path to user file. ### Returns None ### Exceptions - Error handler checks severity of the error; run or exit. ``` -------------------------------- ### copy_src_dst(rec_dst, rec_src, buf_size) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Copies the recorder file to the user file. The file must be bigger than one chunk of the radio stream. ```APIDOC ## copy_src_dst(rec_dst, rec_src, buf_size) ### Description Copy recorder file to user file. File must be bigger than one chunk of radio stream. ### Parameters - **rec_src**: absolute path to recorder file - **rec_dst**: absolute path to user file - **buf_size**: chunk size to fit block size of OS ### Raises - **OSError**: on disk fail or folder not writeable ``` -------------------------------- ### bytes_object_get(file_obj) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Read file from path (str file_obj), if it is no file stream. Returns the file content as bytes. ```APIDOC ## bytes_object_get(file_obj) ### Description Read file from path (str file_obj), if it is no file stream. Returns the file content as bytes. ### Method Function call ### Endpoint `ghettorecorder.ghetto_header_aac.bytes_object_get(file_obj)` ### Parameters - **file_obj** (str) - Required - File path or file stream. ### Returns - **bytes** - The file content as bytes. ``` -------------------------------- ### copy_skip(str_radio, recorder_dst) Source: https://github.com/44xtc44/ghettorecorder/blob/dev/docs/source/ghettorecorder.rst Shows the skipped file path. This is used when a file is not copied. ```APIDOC ## copy_skip(str_radio, recorder_dst) ### Description Show skipped file path ### Parameters - **str_radio**: name - **recorder_dst**: absolute path to user file ```