Core API¶
The core module provides the main station orchestrator and configuration.
QFZZStation¶
qfzz.core.station.QFZZStation
¶
Main orchestrator for a QFZZ Radio Station.
Coordinates personalized DJ, dataset management, blockchain trust, edge optimization, and streaming capabilities.
Source code in qfzz/core/station.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
__init__(config)
¶
Initialize QFZZ Station.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
StationConfig
|
Station configuration |
required |
Source code in qfzz/core/station.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
add_listener(user_id, preferences=None)
¶
Add a listener to the station.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
Unique user identifier |
required |
preferences
|
Optional[dict[str, Any]]
|
Optional user preferences |
None
|
Source code in qfzz/core/station.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
generate_playlist(user_id)
¶
Generate personalized playlist for a user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
User identifier |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of track dictionaries |
Source code in qfzz/core/station.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
get_station_stats()
¶
Get current station statistics.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary of station statistics |
Source code in qfzz/core/station.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
is_running()
¶
Check if station is running.
Source code in qfzz/core/station.py
222 223 224 | |
record_interaction(user_id, track_id, interaction_type, rating=None)
¶
Record user interaction with a track.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
User identifier |
required |
track_id
|
str
|
Track identifier |
required |
interaction_type
|
str
|
Type of interaction (play, skip, like, etc.) |
required |
rating
|
Optional[float]
|
Optional rating value |
None
|
Source code in qfzz/core/station.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
remove_listener(user_id)
¶
Remove a listener from the station.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
User identifier to remove |
required |
Source code in qfzz/core/station.py
127 128 129 130 131 132 133 134 135 136 | |
start()
¶
Start the radio station.
Source code in qfzz/core/station.py
44 45 46 47 48 49 50 51 52 53 | |
stop()
¶
Stop the radio station.
Source code in qfzz/core/station.py
55 56 57 58 59 60 61 62 63 64 | |
StationConfig¶
qfzz.core.config.StationConfig
dataclass
¶
Configuration for a QFZZ Radio Station.
Attributes:
| Name | Type | Description |
|---|---|---|
station_id |
str
|
Unique identifier for the station |
station_name |
str
|
Human-readable station name |
max_playlist_size |
int
|
Maximum number of tracks in playlist |
trust_threshold |
float
|
Minimum trust score for content (0.0-1.0) |
enable_blockchain |
bool
|
Enable blockchain trust network |
enable_edge_optimization |
bool
|
Enable edge device optimization |
streaming_quality |
str
|
Default streaming quality |
allowed_licenses |
list[str]
|
List of acceptable content licenses |
cache_size_mb |
int
|
Cache size in megabytes |
metadata |
dict[str, Any]
|
Additional configuration metadata |
Source code in qfzz/core/config.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
__post_init__()
¶
Validate configuration after initialization.
Source code in qfzz/core/config.py
40 41 42 | |
from_dict(data)
classmethod
¶
Create configuration from dictionary.
Source code in qfzz/core/config.py
92 93 94 95 | |
from_json(json_str)
classmethod
¶
Create configuration from JSON string.
Source code in qfzz/core/config.py
97 98 99 100 101 | |
to_dict()
¶
Convert configuration to dictionary.
Source code in qfzz/core/config.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
to_json()
¶
Convert configuration to JSON string.
Source code in qfzz/core/config.py
88 89 90 | |
validate()
¶
Validate configuration parameters.
Raises:
| Type | Description |
|---|---|
ValueError
|
If any configuration parameter is invalid |
Source code in qfzz/core/config.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
Usage Example¶
from qfzz import QFZZStation, StationConfig
# Create configuration
config = StationConfig(
station_name="My Station",
edge_mode=True,
blockchain_enabled=True
)
# Initialize and start station
station = QFZZStation(config)
station.initialize()
station.start()
# Get status
status = station.get_status()
print(status)
# Stop station
station.stop()