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

Migrate from Travis CI to GitHub Actions #10

Merged
merged 33 commits into from
Jun 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2a8a260
Create ci.yaml
carlthome Jun 24, 2023
93d44ab
Delete .travis.yml
carlthome Jun 24, 2023
d58c449
Remove shields
carlthome Jun 24, 2023
1f7d61a
Use reusable workflow
carlthome Jun 24, 2023
e995a25
Delete setup.py
carlthome Jun 24, 2023
18dd4ae
Create pyproject.toml
carlthome Jun 24, 2023
258818d
Remove Python 2 classifiers
carlthome Jun 24, 2023
2159456
`prettier`
carlthome Jun 24, 2023
8744492
`pyupgrade --py36-plus`
carlthome Jun 24, 2023
d44eb9d
Require minimum setuptools that supports project key in pyproject.toml
carlthome Jun 24, 2023
aebcb6b
`prettier`
carlthome Jun 24, 2023
5bbb763
Remove six
carlthome Jun 24, 2023
db43ed8
Don't specify Python 3 minor versions
carlthome Jun 24, 2023
5b837bd
Set black line length to 120
carlthome Jun 24, 2023
2bf644f
`black`
carlthome Jun 24, 2023
aff141b
Add direnv
carlthome Jun 24, 2023
4cdd441
Add development instructions and remove mention of SoundCloud API
carlthome Jun 24, 2023
51eb77c
Install youtube-dl from GitHub
carlthome Jun 24, 2023
c2bd55a
Enable setuptools-scm
carlthome Jun 24, 2023
7ead3ff
Add pre-commit hooks for formatting, etc.
carlthome Jun 25, 2023
6e3d33b
Add lint and test steps
carlthome Jun 25, 2023
91db52d
Replace `pafy` with `youtube-dl`
carlthome Jun 25, 2023
3a6669b
Format
carlthome Jun 25, 2023
aec9095
Add verbose flag
carlthome Jun 25, 2023
0b1a307
Expose __version__
carlthome Jun 25, 2023
1bdd184
Show info logging during pytest
carlthome Jun 25, 2023
1ef890c
Replace soundcloud with sclib
carlthome Jun 25, 2023
9d42678
Add TODO
carlthome Jun 25, 2023
452a2fb
Add TODO
carlthome Jun 25, 2023
0c5ef90
Only test latest push
carlthome Jun 25, 2023
74b9a0b
Add download limit
carlthome Jun 25, 2023
95b8165
Set minimum Python to 3.8
carlthome Jun 25, 2023
b1df8f8
Set job name to package name
carlthome Jun 25, 2023
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
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
layout python
17 changes: 17 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
on:
push:
branches:
- main
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
audioscrape:
uses: carlthome/workflows/.github/workflows/python.yaml@main
with:
package-name: audioscrape
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,6 @@ ENV/
.idea
*.iml


.direnv
version.py
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/asottile/pyupgrade
rev: v3.7.0
hooks:
- id: pyupgrade
args: [--py310-plus]

- repo: https://github.com/pycqa/autoflake
rev: v2.2.0
hooks:
- id: autoflake

- repo: https://github.com/psf/black
rev: "23.3.0"
hooks:
- id: black
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

49 changes: 35 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,56 @@
# Audioscrape
[![Build Status](https://travis-ci.org/carlthome/audio-scraper.svg?branch=master)](https://travis-ci.org/carlthome/audio-scraper)
[![PyPI](https://img.shields.io/pypi/v/audioscrape.svg)](https://pypi.python.org/pypi/audioscrape)
[![PyPI](https://img.shields.io/pypi/pyversions/audioscrape.svg)](http://py3readiness.org/)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](LICENSE)

Scrape audio from various websites with a simple command-line interface.

# Install
First make sure Python and pip are installed, then run:
## Usage

First make sure Python is installed, then run:

```sh
pip install audioscrape
```

# Usage
Then you can use the program as:

```sh
audioscrape "acoustic guitar"
```

See `audioscrape --help` for more details.

## Python API
You could also use the scraper directly in Python, as:
### Python API

You can also use the scraper directly in Python, as:

```python
import audioscrape

audioscrape.download(query='Cerulean Crayons',
include=['guitar'],
exclude=['remix'],
audioscrape.download(query="Cerulean Crayons",
include=["guitar"],
exclude=["remix"],
quiet=True)
```

## SoundCloud API key and download limits
This program uses SoundCloud's official Python API which requires a registered API key. SoundCloud says an API key can be used for 15,000 requests per any 24-hour time window, and a key has been included in the program. However, in case the key stops working, register another one [as described by SoundCloud here](https://github.com/soundcloud/soundcloud-python#basic-use), and use the scraper after setting the environment variable `SOUNDCLOUD_API_KEY`, as `SOUNDCLOUD_API_KEY="your_key" audioscrape "piano music"`.
## Develop

First clone the repo and set it as working directory. Then install the package in development mode (preferably within its own virtual environment):

```sh
pip install -e .
```

If you have `direnv` installed, you can run `direnv allow` to automatically create and activate a Python virtual environment when you enter the directory.

### Test

```sh
pytest
```

### Lint

```sh
pre-commit run --all-files
```

Or `pre-commit install` to run automatically on `git commit`.
6 changes: 4 additions & 2 deletions audioscrape/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# coding=utf-8
"""YouTube audio scraper package."""
from .__main__ import download
__all__ = ['download']
from .version import version

__all__ = ["download"]
__version__ = version
66 changes: 24 additions & 42 deletions audioscrape/__main__.py
Original file line number Diff line number Diff line change
@@ -1,61 +1,43 @@
# coding=utf-8
"""Download audio."""
import argparse
import logging
import sys

from . import soundcloud, youtube

logger = logging.getLogger(__name__)

def download(query, include=None, exclude=None, quiet=False, overwrite=False):

def download(query, include, exclude, quiet, verbose, overwrite, limit):
"""Scrape various websites for audio."""
youtube.scrape(query, include, exclude, quiet, overwrite)
soundcloud.scrape(query, include, exclude, quiet, overwrite)
youtube.scrape(query, include, exclude, quiet, verbose, overwrite, limit)
soundcloud.scrape(query, include, exclude, quiet, verbose, overwrite, limit)


def cli(args=None):
"""CLI for scraping audio."""

parser = argparse.ArgumentParser()
parser.add_argument(
'query',
default="Cerulean Crayons",
nargs='?',
help="search terms")
parser.add_argument(
'-i',
'--include',
default=[],
action='append',
help="only download audio with this tag"
)
parser.add_argument(
'-e',
'--exclude',
default=[],
action='append',
help="ignore results with this tag"
)
parser.add_argument(
'-q',
'--quiet',
default=False,
action='store_true',
help="hide progress reporting")
parser.add_argument(
'-o',
'--overwrite',
default=False,
action='store_true',
help="overwrite existing files")
parser.add_argument("query", default="Cerulean Crayons", nargs="?", help="search terms")
parser.add_argument("-i", "--include", default=[], action="append", help="only download audio with this tag")
parser.add_argument("-e", "--exclude", default=[], action="append", help="ignore results with this tag")
parser.add_argument("-q", "--quiet", default=False, action="store_true", help="hide progress reporting")
parser.add_argument("-v", "--verbose", default=False, action="store_true", help="display debug information")
parser.add_argument("-o", "--overwrite", default=False, action="store_true", help="overwrite existing files")
parser.add_argument("-l", "--limit", default=10, type=int, help="limit number of downloads")
args = parser.parse_args()

if not args.quiet:
print('Downloading audio from "{}" videos tagged {} and not {}.'.
format(args.query, args.include, args.exclude))
download(args.query, args.include, args.exclude, args.quiet,
args.overwrite)
if not args.quiet:
print("Finished downloading audio.")
logging.basicConfig(format="[%(name)s] %(message)s")
if args.verbose:
logger.setLevel(logging.DEBUG)
elif args.quiet:
logger.setLevel(logging.ERROR)
else:
logger.setLevel(logging.INFO)

logger.info(f'Downloading audio from "{args.query}" videos tagged {args.include} and not {args.exclude}.')
download(args.query, args.include, args.exclude, args.quiet, args.verbose, args.overwrite, args.limit)
logger.info("Finished downloading audio.")


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions audioscrape/classify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO Add machine listening help functionality to easily categorize downloaded audio.
1 change: 1 addition & 0 deletions audioscrape/freesound.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO
Loading