mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2026-01-01 09:20:40 +00:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
edbe748718 | ||
|
|
2019a4ec63 | ||
|
|
fb43838c7d | ||
|
|
4cd58b8ddd | ||
|
|
38dab7723f | ||
|
|
354d88a5b2 | ||
|
|
d8a405b6d2 | ||
|
|
5f7e467fbd | ||
|
|
3377ddb4b9 | ||
|
|
9cd6cf7f12 | ||
|
|
1f8ebe253b | ||
|
|
fe46d1b242 | ||
|
|
b213933ad8 | ||
|
|
7e314f7475 | ||
|
|
b2d6fd3c92 | ||
|
|
c4d8608c8f | ||
|
|
5605b05f9f | ||
|
|
5d71cabda7 | ||
|
|
c2f87b1fef | ||
|
|
3db40d4f12 | ||
|
|
40b30f5bd8 | ||
|
|
048f20c64c | ||
|
|
6a69df2ee8 | ||
|
|
ec327ee76f | ||
|
|
62a34cfee8 |
13
.coveragerc
13
.coveragerc
@@ -1,13 +0,0 @@
|
|||||||
[run]
|
|
||||||
branch = True
|
|
||||||
source = wavinfo
|
|
||||||
|
|
||||||
[report]
|
|
||||||
exclude_lines =
|
|
||||||
if self.debug:
|
|
||||||
pragma: no cover
|
|
||||||
raise NotImplementedError
|
|
||||||
if __name__ == .__main__.:
|
|
||||||
ignore_errors = True
|
|
||||||
omit =
|
|
||||||
tests/*
|
|
||||||
42
.github/workflows/python-package.yml
vendored
Normal file
42
.github/workflows/python-package.yml
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
|
||||||
|
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
|
||||||
|
|
||||||
|
name: Python Lint and Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "master" ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "master" ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
python-version: ["3.8", "3.9", "3.10"]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2.5.0
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v4.3.0
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
python -m pip install flake8 pytest
|
||||||
|
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
||||||
|
- name: Setup FFmpeg
|
||||||
|
uses: FedericoCarboni/setup-ffmpeg@v2
|
||||||
|
- name: Lint with flake8
|
||||||
|
run: |
|
||||||
|
# stop the build if there are Python syntax errors or undefined names
|
||||||
|
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||||
|
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
||||||
|
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||||
|
- name: Test with pytest
|
||||||
|
run: |
|
||||||
|
pytest
|
||||||
2
.github/workflows/pythonpublish.yml
vendored
2
.github/workflows/pythonpublish.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
|||||||
pip install setuptools wheel twine lxml
|
pip install setuptools wheel twine lxml
|
||||||
- name: Build and publish
|
- name: Build and publish
|
||||||
env:
|
env:
|
||||||
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
|
TWINE_USERNAME: __token__
|
||||||
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
|
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
|
||||||
run: |
|
run: |
|
||||||
python setup.py sdist bdist_wheel
|
python setup.py sdist bdist_wheel
|
||||||
|
|||||||
27
.travis.yml
27
.travis.yml
@@ -1,27 +0,0 @@
|
|||||||
dist: xenial
|
|
||||||
language: python
|
|
||||||
python:
|
|
||||||
# - "2.7"
|
|
||||||
# - "3.5"
|
|
||||||
- "3.6"
|
|
||||||
- "3.7"
|
|
||||||
- "3.8"
|
|
||||||
- "3.9"
|
|
||||||
script:
|
|
||||||
- "gunzip tests/test_files/rf64/*.gz"
|
|
||||||
- "python setup.py test"
|
|
||||||
- "python -m pytest tests/ -v --cov wavinfo --cov-report term-missing"
|
|
||||||
before_install:
|
|
||||||
- "sudo apt-get update"
|
|
||||||
- "sudo add-apt-repository universe"
|
|
||||||
- "sudo apt-get install -y ffmpeg"
|
|
||||||
- "pip install pytest"
|
|
||||||
- "pip install lxml"
|
|
||||||
- "pip install coverage"
|
|
||||||
- "pip install codecov"
|
|
||||||
- "pip install pytest-cov==2.5.0"
|
|
||||||
- "pip install coverage==4.4"
|
|
||||||
install:
|
|
||||||
- "pip install setuptools"
|
|
||||||
after_success:
|
|
||||||
- "codecov"
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
[](https://travis-ci.com/iluvcapra/wavinfo)
|
|
||||||
[](https://codecov.io/gh/iluvcapra/wavinfo)
|
|
||||||
[](https://wavinfo.readthedocs.io/en/latest/?badge=latest)   [](https://pypi.org/project/wavinfo/) 
|
[](https://wavinfo.readthedocs.io/en/latest/?badge=latest)   [](https://pypi.org/project/wavinfo/) 
|
||||||
|

|
||||||
|
|
||||||
<!--  -->
|
<!--  -->
|
||||||
|
|
||||||
@@ -60,10 +59,6 @@ The length of the file in frames (interleaved samples) and bytes is available, a
|
|||||||
>>> (48000, 2, 6, 24)
|
>>> (48000, 2, 6, 24)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Platform Lifecycle Stuff
|
|
||||||
|
|
||||||
Python 3.5 support is deprecated.
|
|
||||||
|
|
||||||
## Other Resources
|
## Other Resources
|
||||||
|
|
||||||
* For other file formats and ID3 decoding, look at [audio-metadata](https://github.com/thebigmunch/audio-metadata).
|
* For other file formats and ID3 decoding, look at [audio-metadata](https://github.com/thebigmunch/audio-metadata).
|
||||||
|
|||||||
6
metadata.py
Normal file
6
metadata.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
"""
|
||||||
|
Wavinfo
|
||||||
|
"""
|
||||||
|
__version__ = '1.7.0'
|
||||||
|
__author__ = 'Jamie Hardt <jamiehardt@gmail.com>'
|
||||||
|
__license__ = "MIT"
|
||||||
@@ -1,3 +1,19 @@
|
|||||||
lxml>=4.6.5
|
attrs==21.4.0
|
||||||
setuptools~=49.6.0
|
ear==2.1.0
|
||||||
ear~=2.0.0
|
enum34==1.1.10
|
||||||
|
exceptiongroup==1.0.4
|
||||||
|
iniconfig==1.1.1
|
||||||
|
lxml==4.9.1
|
||||||
|
multipledispatch==0.6.0
|
||||||
|
numpy==1.23.3
|
||||||
|
packaging==21.3
|
||||||
|
pluggy==1.0.0
|
||||||
|
pyparsing==3.0.9
|
||||||
|
pytest==7.2.0
|
||||||
|
ruamel.yaml==0.17.21
|
||||||
|
ruamel.yaml.clib==0.2.6
|
||||||
|
scipy==1.9.1
|
||||||
|
six==1.16.0
|
||||||
|
style==1.1.0
|
||||||
|
tomli==2.0.1
|
||||||
|
update==0.0.1
|
||||||
|
|||||||
5
setup.py
5
setup.py
@@ -1,5 +1,5 @@
|
|||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
from wavinfo import __author__, __license__, __version__
|
from metadata import __author__, __license__, __version__
|
||||||
|
|
||||||
with open("README.md", "r") as fh:
|
with open("README.md", "r") as fh:
|
||||||
long_description = fh.read()
|
long_description = fh.read()
|
||||||
@@ -26,9 +26,6 @@ setup(name='wavinfo',
|
|||||||
'License :: OSI Approved :: MIT License',
|
'License :: OSI Approved :: MIT License',
|
||||||
'Topic :: Multimedia',
|
'Topic :: Multimedia',
|
||||||
'Topic :: Multimedia :: Sound/Audio',
|
'Topic :: Multimedia :: Sound/Audio',
|
||||||
# "Programming Language :: Python :: 3.5",
|
|
||||||
"Programming Language :: Python :: 3.6",
|
|
||||||
"Programming Language :: Python :: 3.7",
|
|
||||||
"Programming Language :: Python :: 3.8",
|
"Programming Language :: Python :: 3.8",
|
||||||
"Programming Language :: Python :: 3.9",
|
"Programming Language :: Python :: 3.9",
|
||||||
"Programming Language :: Python :: 3.10"],
|
"Programming Language :: Python :: 3.10"],
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class TestWaveInfo(TestCase):
|
|||||||
def test_sanity(self):
|
def test_sanity(self):
|
||||||
for wav_file in all_files():
|
for wav_file in all_files():
|
||||||
info = wavinfo.WavInfoReader(wav_file)
|
info = wavinfo.WavInfoReader(wav_file)
|
||||||
self.assertEqual(info.__repr__(), 'WavInfoReader(%s, %s, %s)'.format(wav_file, 'latin_1', 'ascii'))
|
self.assertEqual(info.__repr__(), 'WavInfoReader({}, latin_1, ascii)'.format(os.path.abspath(wav_file)))
|
||||||
self.assertIsNotNone(info)
|
self.assertIsNotNone(info)
|
||||||
|
|
||||||
def test_fmt_against_ffprobe(self):
|
def test_fmt_against_ffprobe(self):
|
||||||
|
|||||||
@@ -7,6 +7,3 @@ Go to the documentation for wavinfo.WavInfoReader for more information.
|
|||||||
from .wave_reader import WavInfoReader
|
from .wave_reader import WavInfoReader
|
||||||
from .riff_parser import WavInfoEOFError
|
from .riff_parser import WavInfoEOFError
|
||||||
|
|
||||||
__version__ = '1.6.3'
|
|
||||||
__author__ = 'Jamie Hardt <jamiehardt@gmail.com>'
|
|
||||||
__license__ = "MIT"
|
|
||||||
|
|||||||
@@ -27,43 +27,57 @@ class WavInfoReader:
|
|||||||
"""
|
"""
|
||||||
Create a new reader object.
|
Create a new reader object.
|
||||||
|
|
||||||
:param path: A filesystem path to the wav file you wish to probe.
|
:param path:
|
||||||
|
A filesystem path to the wav file you wish to probe or a
|
||||||
|
file handle to an open file.
|
||||||
|
|
||||||
:param info_encoding: The text encoding of the INFO metadata fields.
|
:param info_encoding:
|
||||||
latin_1/Win CP1252 has always been a pretty good guess for this.
|
The text encoding of the INFO metadata fields.
|
||||||
|
latin_1/Win CP1252 has always been a pretty good guess for this.
|
||||||
|
|
||||||
:param bext_encoding: The text encoding to use when decoding the string
|
:param bext_encoding:
|
||||||
fields of the Broadcast-WAV extension. Per EBU 3285 this is ASCII
|
The text encoding to use when decoding the string
|
||||||
but this parameter is available to you if you encounter a weirdo.
|
fields of the Broadcast-WAV extension. Per EBU 3285 this is ASCII
|
||||||
|
but this parameter is available to you if you encounter a weirdo.
|
||||||
"""
|
"""
|
||||||
absolute_path = os.path.abspath(path)
|
|
||||||
|
|
||||||
#: `file://` url for the file.
|
|
||||||
self.url = pathlib.Path(absolute_path).as_uri()
|
|
||||||
|
|
||||||
# for __repr__()
|
|
||||||
self.path = absolute_path
|
|
||||||
self.info_encoding = info_encoding
|
self.info_encoding = info_encoding
|
||||||
self.bext_encoding = bext_encoding
|
self.bext_encoding = bext_encoding
|
||||||
|
|
||||||
with open(path, 'rb') as f:
|
if hasattr(path, 'read'):
|
||||||
chunks = parse_chunk(f)
|
self.get_wav_info(path)
|
||||||
|
self.url = 'about:blank'
|
||||||
|
self.path = repr(path)
|
||||||
|
else:
|
||||||
|
absolute_path = os.path.abspath(path)
|
||||||
|
|
||||||
self.main_list = chunks.children
|
#: `file://` url for the file.
|
||||||
f.seek(0)
|
self.url = pathlib.Path(absolute_path).as_uri()
|
||||||
|
|
||||||
#: :class:`wavinfo.wave_reader.WavAudioFormat`
|
# for __repr__()
|
||||||
self.fmt = self._get_format(f)
|
self.path = absolute_path
|
||||||
|
|
||||||
#: :class:`wavinfo.wave_bext_reader.WavBextReader` with Broadcast-WAV metadata
|
with open(path, 'rb') as f:
|
||||||
self.bext = self._get_bext(f, encoding=bext_encoding)
|
self.get_wav_info(f)
|
||||||
|
|
||||||
#: :class:`wavinfo.wave_ixml_reader.WavIXMLFormat` with iXML metadata
|
def get_wav_info(self, wavfile):
|
||||||
self.ixml = self._get_ixml(f)
|
chunks = parse_chunk(wavfile)
|
||||||
|
|
||||||
#: :class:`wavinfo.wave_info_reader.WavInfoChunkReader` with RIFF INFO metadata
|
self.main_list = chunks.children
|
||||||
self.info = self._get_info(f, encoding=info_encoding)
|
wavfile.seek(0)
|
||||||
self.data = self._describe_data()
|
|
||||||
|
#: :class:`wavinfo.wave_reader.WavAudioFormat`
|
||||||
|
self.fmt = self._get_format(wavfile)
|
||||||
|
|
||||||
|
#: :class:`wavinfo.wave_bext_reader.WavBextReader` with Broadcast-WAV metadata
|
||||||
|
self.bext = self._get_bext(wavfile, encoding=self.bext_encoding)
|
||||||
|
|
||||||
|
#: :class:`wavinfo.wave_ixml_reader.WavIXMLFormat` with iXML metadata
|
||||||
|
self.ixml = self._get_ixml(wavfile)
|
||||||
|
|
||||||
|
#: :class:`wavinfo.wave_info_reader.WavInfoChunkReader` with RIFF INFO metadata
|
||||||
|
self.info = self._get_info(wavfile, encoding=self.info_encoding)
|
||||||
|
self.data = self._describe_data()
|
||||||
|
|
||||||
def _find_chunk_data(self, ident, from_stream, default_none=False):
|
def _find_chunk_data(self, ident, from_stream, default_none=False):
|
||||||
top_chunks = (chunk for chunk in self.main_list if type(chunk) is ChunkDescriptor and chunk.ident == ident)
|
top_chunks = (chunk for chunk in self.main_list if type(chunk) is ChunkDescriptor and chunk.ident == ident)
|
||||||
@@ -146,4 +160,4 @@ class WavInfoReader:
|
|||||||
yield 'info', key, info_dict[key]
|
yield 'info', key, info_dict[key]
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'WavInfoReader(%s, %s, %s)'.format(self.path, self.info_encoding, self.bext_encoding)
|
return 'WavInfoReader({}, {}, {})'.format(self.path, self.info_encoding, self.bext_encoding)
|
||||||
|
|||||||
Reference in New Issue
Block a user