forked from beetbox/mediafile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ingo Fischer
committed
Jan 6, 2020
1 parent
75ad2c6
commit 2956c4d
Showing
10 changed files
with
190 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,10 @@ | ||
dist: trusty | ||
language: python | ||
sudo: false | ||
|
||
env: | ||
global: | ||
# Undocumented feature of nose-show-skipped. | ||
NOSE_SHOW_SKIPPED: 1 | ||
services: | ||
- docker | ||
|
||
matrix: | ||
include: | ||
- python: 2.7.13 | ||
env: {TOX_ENV: py27-cov, COVERAGE: 1} | ||
- python: 2.7.13 | ||
env: {TOX_ENV: py27-test} | ||
- python: 3.4 | ||
env: {TOX_ENV: py34-test} | ||
- python: 3.5 | ||
env: {TOX_ENV: py35-test} | ||
- python: 3.6 | ||
env: {TOX_ENV: py36-test} | ||
- python: 3.7 | ||
env: {TOX_ENV: py37-test} | ||
dist: xenial | ||
- python: 3.8-dev | ||
env: {TOX_ENV: py38-test} | ||
dist: xenial | ||
- python: pypy | ||
env: {TOX_ENV: pypy-test} | ||
- python: 2.7 | ||
env: {TOX_ENV: py27-flake8} | ||
- python: 3.5 | ||
env: {TOX_ENV: py35-flake8} | ||
|
||
# Non-Python dependencies. | ||
addons: | ||
apt: | ||
packages: | ||
- bash-completion | ||
|
||
# To install dependencies, tell tox to do everything but actually running the | ||
# test. | ||
install: | ||
- travis_retry pip install 'tox<=3.8.1' | ||
- travis_retry tox -e $TOX_ENV --notest | ||
|
||
script: | ||
- tox -e $TOX_ENV | ||
|
||
# Report coverage to codecov.io. | ||
before_install: | ||
- "[ ! -z $COVERAGE ] && travis_retry pip install codecov || true" | ||
after_success: | ||
- "[ ! -z $COVERAGE ] && codecov || true" | ||
- make build | ||
|
||
cache: | ||
pip: true | ||
script: | ||
- make tox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import os | ||
from mediafile import * | ||
from mutagen.id3 import ID3, POPM | ||
|
||
# import hunter | ||
# hunter.trace(action=hunter.CallPrinter) | ||
|
||
|
||
def mutagen_inspect(filename): | ||
os.system(f"mutagen-inspect {filename} | grep POP") | ||
|
||
|
||
def clear_popm(filename): | ||
id3 = ID3(filename) | ||
id3.delall('POPM') | ||
id3.save() | ||
|
||
|
||
def clear_priv(filename): | ||
id3 = ID3(filename) | ||
id3.delall('PRIV') | ||
id3.save() | ||
|
||
|
||
def set_popm_mutagen(filename, email, rating=None, count=None): | ||
id3 = ID3(filename) | ||
id3['POPM'] = POPM(email=email, rating=rating, count=count) | ||
id3.save() | ||
|
||
|
||
def set_popm_mediafile(filename, email, rating, count): | ||
mf = MediaFile(filename) | ||
mf.popm = POPM(email=email, rating=rating, count=count) | ||
mf.save() | ||
|
||
|
||
def get_popm_mutagen(filename): | ||
id3 = ID3(filename) | ||
return id3.getall('POPM') | ||
|
||
|
||
def get_popm_mediafile(filename): | ||
mf = MediaFile(filename) | ||
return mf.popm | ||
|
||
|
||
if __name__ == '__main__': | ||
filename = 'test/rsrc/popm.mp3' | ||
clear_popm(filename) | ||
clear_priv(filename) | ||
|
||
set_popm_mutagen(filename, email='[email protected]', rating=5) | ||
print(get_popm_mutagen(filename)) | ||
|
||
clear_popm(filename) | ||
|
||
# set_popm_mutagen(filename, email='[email protected]', count=5) | ||
# print(get_popm_mutagen(filename)) | ||
|
||
# set_popm_mediafile(filename, email='[email protected]', rating=5, count=5) | ||
# set_popm_mediafile(filename, email='[email protected]', rating=5, count=5) | ||
# print("after: {}".format(get_popm_mediafile(filename))) | ||
# | ||
# mf = MediaFile(filename) | ||
# from ipdb import set_trace; set_trace() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
hunter==3.0.5 | ||
ipdb==0.12.3 | ||
ipython==7.10.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
popm_tags = mediafile.mgfile.tags.getall('POPM') | ||
return { | ||
tag.email: Popularimeter(email=tag.email, rating=tag.rating, count=tag.count) | ||
for tag in popm_tags | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,11 +23,12 @@ | |
import datetime | ||
import time | ||
import unittest | ||
|
||
from six import assertCountEqual | ||
|
||
from test import _common | ||
from mediafile import MediaFile, Image, \ | ||
ImageType, CoverArtField, UnreadableFileError | ||
from mediafile import MediaFile, Image, ImageType, CoverArtField, \ | ||
UnreadableFileError | ||
|
||
|
||
class ArtTestMixin(object): | ||
|
@@ -755,6 +756,37 @@ def test_unknown_apic_type(self): | |
mediafile = self._mediafile_fixture('image_unknown_type') | ||
self.assertEqual(mediafile.images[0].type, ImageType.other) | ||
|
||
def test_write_single_popm(self): | ||
mediafile = self._mediafile_fixture('empty') | ||
test_email = '[email protected]' | ||
mediafile.popm = { | ||
test_email: {'rating': 1, 'count': 1} | ||
} | ||
mediafile.save() | ||
self.assertEqual(mediafile.popm, { | ||
test_email: {'rating': 1, 'count': 1} | ||
}) | ||
|
||
def test_write_popm_without_count(self): | ||
mediafile = self._mediafile_fixture('empty') | ||
test_email = '[email protected]' | ||
mediafile.popm = {test_email: {'rating': 1}} | ||
mediafile.save() | ||
self.assertEqual(mediafile.popm, { | ||
test_email: {'rating': 1, 'count': 0} | ||
}) | ||
|
||
def test_write_multiple_popm(self): | ||
mediafile = self._mediafile_fixture('full') | ||
mediafile.popm = {'[email protected]': {'rating': 1, 'count': 1}, | ||
'[email protected]': {'rating': 2, 'count': 2}} | ||
mediafile.save() | ||
|
||
self.assertEqual(mediafile.popm, { | ||
'[email protected]': {'rating': 1, 'count': 1}, | ||
'[email protected]': {'rating': 2, 'count': 2}, | ||
}) | ||
|
||
|
||
class MP4Test(ReadWriteTestBase, PartialTestMixin, | ||
ImageStructureTestMixin, unittest.TestCase): | ||
|
@@ -975,7 +1007,7 @@ def test_properties_from_readable_fields(self): | |
|
||
def test_known_fields(self): | ||
fields = list(ReadWriteTestBase.tag_fields) | ||
fields.extend(('encoder', 'images', 'genres', 'albumtype')) | ||
fields.extend(('encoder', 'images', 'genres', 'albumtype', 'popm')) | ||
assertCountEqual(self, MediaFile.fields(), fields) | ||
|
||
def test_fields_in_readable_fields(self): | ||
|