Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/hogum/audioConvertor into…
Browse files Browse the repository at this point in the history
… travis
  • Loading branch information
mugoh committed Aug 5, 2019
2 parents ad65da9 + 9135a13 commit dac848b
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 18 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
language: python
cache: pip
cache:
pip: true
python:
- "3.6"
sudo: true

before_install:
- sudo apt-get install -y ffmpeg

before_script:
- pip install coverage
- pip install coveralls
Expand Down
7 changes: 4 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[[source]]
url = "https://pypi.org/simple"
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[packages]
ffmpeg = "*"
click = "*"
pytest = "*"

[dev-packages]

[requires]
python_version = "3.6"
python_version = "3.7"
99 changes: 93 additions & 6 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# audioConvertor [![Build Status](https://travis-ci.org/hogum/audioConvertor.svg?branch=master)](https://travis-ci.org/hogum/audioConvertor)

audioConvertor is a multifile media format convertor command line tool. It allows conversion of files to various media types, the most emphasised on, being from video to audio.
The tool is guide detailed out on [this blog post](https://medium.com/@mugoh.ks/python-click-building-your-first-command-line-interface-application-6947d5319ef7)
The tool is a guide detailed out on [this blog post](https://medium.com/@mugoh.ks/python-click-building-your-first-command-line-interface-application-6947d5319ef7)

### Setup
1. Access a cloned copy of the repo
Expand All @@ -19,6 +19,22 @@ The tool is guide detailed out on [this blog post](https://medium.com/@mugoh.ks/
```shell
$ apt-get install ffmpeg
```

### Dependecies

1. Ensure to have pipenv installed
```shell
$ apt install pipenv
```
2. Install the project dependencies by running
```shell
$ pipenv install
```
- Alternatively, you can use a virtual environment with dependencies present by running
```shell
$ pipenv shell
```

### Interacting with the application

#### Basic Usage
Expand Down Expand Up @@ -46,3 +62,14 @@ The usage options are accesible on the help menu. This can be displayed by runni
```


### Testing
1. Spawn a virtual environment

```shell
$ pipenv shell
```

2. Run tests
```shell
$ pytest
```
11 changes: 5 additions & 6 deletions convertor/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
def main(ctx, verbose):
group_commands = ['convert', 'play']
"""
audioConvertor is a command line tool that helps convert video files
to audio file formats.\n
example: python convertor/cli.py -i input/file/path -o output/path
audioConvertor is a command line tool that helps convert video files
to audio file formats.\n
example: python convertor/cli.py -i input/file/path -o output/path
"""
ctx.obj = {} if not ctx.obj else ctx.obj
Expand Down Expand Up @@ -134,6 +134,7 @@ def load_audio(ctx, playlist, recursive, player):
click.echo(click.style('Specify the file playlist location', fg='red'))
return

playlist = playlist[0] if not isinstance(playlist, str) else playlist
if recursive:
try:

Expand All @@ -152,6 +153,7 @@ def load_audio(ctx, playlist, recursive, player):
return

if not convertor_instance.is_video(playlist):
playlist = playlist[0] if not isinstance(playlist, str) else playlist
click.echo(click.style(
playlist + " is not a supported media type", fg='red'))
return
Expand All @@ -176,6 +178,3 @@ def flatten(iterable):


convertor_instance = Convertor()

if __name__ == '__main__':
main()
6 changes: 5 additions & 1 deletion convertor/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ def is_video(self, given_file):
"""
video_extensions = ['mp4', 'flv', 'avi', 'mp3', 'flaac']

if not isinstance(given_file, str):
try: # iter in play cmd
given_file = given_file[0]
except TypeError:
given_file = given_file
return any([ext for ext in video_extensions
if given_file.endswith(ext)])

Expand Down Expand Up @@ -152,7 +157,6 @@ def open_player(self, cmd=[], play_items=[]):
system architecture.
"""
commands = [cmd] + play_items

try:
subprocess.check_call(commands)
except subprocess.CalledProcessError as er:
Expand Down
4 changes: 4 additions & 0 deletions run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from convertor.cli import main

if __name__ == '__main__':
main()
19 changes: 19 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import setuptools

with open("README.md", "r") as fp:
alt_description = fp.read()


setuptools.setup(
name="convertor-mugoh",
version="0.0.1",
author="mugoh",
description="A video to audio convertor",
long_decsription=alt_description,
long_decsription_content_type="text/markdown",
url="https://github.com/hogum/audioConvertor",
packages=['convertor']
classifers=["Programming Language :: Python :: 3",
"Licence :: Apache GPL 2",
],
)

0 comments on commit dac848b

Please sign in to comment.