Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default replay gain #1259

Merged
merged 1 commit into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion python_apps/api_clients/api_clients/version2.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_schedule(self):
result = {"media": {}}
for item in data:
start = isoparse(item["starts"])
key = start.strftime("%YYYY-%mm-%dd-%HH-%MM-%SS")
key = start.strftime("%Y-%m-%d-%H-%M-%S")
end = isoparse(item["ends"])

show_instance = self.services.show_instance_url(id=item["instance_id"])
Expand All @@ -69,6 +69,7 @@ def get_schedule(self):
"start": start.strftime("%Y-%m-%d-%H-%M-%S"),
"end": end.strftime("%Y-%m-%d-%H-%M-%S"),
"row_id": item["id"],
"show_name": show["name"],
}
current = result["media"][key]
if item["file"]:
Expand All @@ -90,6 +91,7 @@ def get_schedule(self):
info = self.services.file_url(id=item["file_id"])
current["metadata"] = info
current["uri"] = item["file"]
current["replay_gain"] = info["replay_gain"]
current["filesize"] = info["filesize"]
elif item["stream"]:
current["independent_event"] = True
Expand Down
1 change: 1 addition & 0 deletions python_apps/api_clients/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
install_requires=[
"configobj",
"python-dateutil>=2.7.0",
"requests",
],
zip_safe=False,
data_files=[],
Expand Down
108 changes: 108 additions & 0 deletions python_apps/api_clients/tests/version2_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import pytest
from api_clients.utils import RequestProvider
from api_clients.version2 import AirtimeApiClient, api_config


@pytest.fixture()
def config():
return {
**api_config,
"general": {
"base_dir": "/test",
"base_port": 80,
"base_url": "localhost",
"api_key": "TEST_KEY",
},
"api_base": "api",
}


class MockRequestProvider:
@staticmethod
def schedule_url(_post_data=None, params=None, **kwargs):
return [
{
"id": 1,
"starts": "2021-07-05T11:00:00Z",
"ends": "2021-07-05T11:01:00.5000Z",
"instance_id": 2,
"file": "http://localhost/api/v2/file/3",
"file_id": 3,
"fade_in": "00:00:00.500000",
"fade_out": "00:00:01",
"cue_in": "00:00:00.142404",
"cue_out": "01:58:04.463583",
},
]

@staticmethod
def show_instance_url(_post_data=None, params=None, **kwargs):
return {
"show_id": 4,
}

@staticmethod
def show_url(_post_data=None, params=None, **kwargs):
return {
"name": "Test show",
}

@staticmethod
def file_url(_post_data=None, params=None, **kwargs):
return {
"item_url": "http://localhost/api/v2/files/3/",
"name": "",
"mime": "audio/mp3",
"ftype": "audioclip",
"filepath": "imported/1/test.mp3",
"import_status": 0,
"currently_accessing": 0,
"mtime": "2021-07-01T23:13:43Z",
"utime": "2021-07-01T23:12:46Z",
"md5": "202ae33a642ce475bd8b265ddb11c139",
"track_title": "Test file.mp3",
"bit_rate": 320000,
"sample_rate": 44100,
"length": "01:58:04.463600",
"genre": "Test",
"channels": 2,
"file_exists": True,
"replay_gain": "-5.68",
"cuein": "00:00:00.142404",
"cueout": "01:58:04.463583",
"silan_check": False,
"hidden": False,
"is_scheduled": True,
"is_playlist": False,
"filesize": 283379568,
"track_type": "MUS",
"directory": "http://localhost/api/v2/music-dirs/1/",
"owner": "http://localhost/api/v2/users/1/",
}


def test_get_schedule(monkeypatch, config):
client = AirtimeApiClient(None, config)
client.services = MockRequestProvider()
schedule = client.get_schedule()
assert schedule == {
"media": {
"2021-07-05-11-00-00": {
"id": 3,
"type": "file",
"metadata": MockRequestProvider.file_url(),
"row_id": 1,
"uri": "http://localhost/api/v2/file/3",
"fade_in": 500.0,
"fade_out": 1000.0,
"cue_in": 0.142404,
"cue_out": 7084.463583,
"start": "2021-07-05-11-00-00",
"end": "2021-07-05-11-01-00",
"show_name": "Test show",
"replay_gain": "-5.68",
"independent_event": False,
"filesize": 283379568,
},
},
}