Skip to content

Commit

Permalink
ci: various ci fixes (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
es3n1n authored Jul 9, 2024
1 parent 13ff943 commit 63142ed
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: FedericoCarboni/setup-ffmpeg@v3
- name: Install ffmpeg
run: |
sudo apt update
sudo apt install -yq --no-install-recommends ffmpeg
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand All @@ -33,7 +36,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AUTH_TOKEN: ${{ secrets.AUTH_TOKEN }}
run: |
pytest
pytest --exitfirst
publish:
needs: test
if: startsWith(github.ref, 'refs/tags/v')
Expand Down
21 changes: 20 additions & 1 deletion scdl/scdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,26 @@ def get_transcoding_m3u8(
headers = client._get_default_headers()
if client.auth_token:
headers["Authorization"] = f"OAuth {client.auth_token}"
r = requests.get(url, params={"client_id": client.client_id}, headers=headers)

params = {
"client_id": client.client_id,
}

r: Optional[requests.Response] = None
delay: int = 0

# If we got ratelimited
while not r or r.status_code == 429:
if delay > 0:
logger.warning(f"Got rate-limited, delaying for {delay}sec")
time.sleep(delay)

r = requests.get(url, headers=headers, params=params)
delay = (delay or 1) * 2 # exponential backoff, what could possibly go wrong

if r.status_code != 200:
raise SoundCloudException(f"Unable to get transcoding m3u8({r.status_code}): {r.text}")

logger.debug(r.url)
return r.json()["url"]
raise SoundCloudException(f"Transcoding does not contain URL: {transcoding}")
Expand Down
1 change: 1 addition & 0 deletions tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def test_reposts(tmp_path: Path) -> None:
"https://soundcloud.com/one-thousand-and-one",
"-r",
"--name-format={title}",
"--onlymp3",
)
assert r.returncode == 0
assert_track(tmp_path, "Wan Bushi - Eurodance Vibes (part 1+2+3).mp3", check_metadata=False)
Expand Down

0 comments on commit 63142ed

Please sign in to comment.