コード例 #1
0
ファイル: importer.py プロジェクト: refreshoxford/beets
import os
import logging
import pickle
from collections import defaultdict

from beets import autotag
from beets import library
import beets.autotag.art
from beets import plugins
from beets import util
from beets.util import pipeline
from beets.util import syspath, normpath, displayable_path
from beets.util.enumeration import enum

action = enum(
    'SKIP', 'ASIS', 'TRACKS', 'MANUAL', 'APPLY', 'MANUAL_ID',
    name='action'
)

QUEUE_SIZE = 128
STATE_FILE = os.path.expanduser('~/.beetsstate')
SINGLE_ARTIST_THRESH = 0.25
VARIOUS_ARTISTS = u'Various Artists'

# Global logger.
log = logging.getLogger('beets')

class ImportAbort(Exception):
    """Raised when the user aborts the tagging operation.
    """
    pass
コード例 #2
0
from collections import defaultdict

from beets import autotag
from beets import library
from beets import plugins
from beets import util
from beets import config
from beets.util import pipeline
from beets.util import syspath, normpath, displayable_path
from beets.util.enumeration import enum
from beets.mediafile import UnreadableFileError

action = enum('SKIP',
              'ASIS',
              'TRACKS',
              'MANUAL',
              'APPLY',
              'MANUAL_ID',
              name='action')

QUEUE_SIZE = 128
SINGLE_ARTIST_THRESH = 0.25
VARIOUS_ARTISTS = u'Various Artists'

# Global logger.
log = logging.getLogger('beets')


class ImportAbort(Exception):
    """Raised when the user aborts the tagging operation.
    """
コード例 #3
0
ファイル: mediafile.py プロジェクト: mdecker/beets
    elif out_type == unicode:
        if val is None:
            return u''
        else:
            return unicode(val)

    else:
        return val


# Flags for encoding field behavior.

# Determine style of packing, if any.
packing = enum('SLASHED', # pair delimited by /
               'TUPLE',   # a python tuple of 2 items
               'DATE',    # YYYY-MM-DD
               name='packing')

class StorageStyle(object):
    """Parameterizes the storage behavior of a single field for a
    certain tag format.
     - key: The Mutagen key used to access the field's data.
     - list_elem: Store item as a single object or as first element
       of a list.
     - as_type: Which type the value is stored as (unicode, int,
       bool, or str).
     - packing: If this value is packed in a multiple-value storage
       unit, which type of packing (in the packing enum). Otherwise,
       None. (Makes as_type irrelevant).
     - pack_pos: If the value is packed, in which position it is
       stored.
コード例 #4
0
ファイル: match.py プロジェクト: Amelandbor/nzbToMedia
"""
from __future__ import division

import datetime
import logging
import re
from munkres import Munkres

from beets import plugins
from beets import config
from beets.util import plurality
from beets.util.enumeration import enum
from beets.autotag import hooks

# Recommendation enumeration.
recommendation = enum('none', 'low', 'medium', 'strong', name='recommendation')

# Artist signals that indicate "various artists". These are used at the
# album level to determine whether a given release is likely a VA
# release and also on the track level to to remove the penalty for
# differing artists.
VA_ARTISTS = (u'', u'various artists', u'various', u'va', u'unknown')

# Global logger.
log = logging.getLogger('beets')


# Primary matching functionality.

def current_metadata(items):
    """Extract the likely current metadata for an album given a list of its
コード例 #5
0
ファイル: mediafile.py プロジェクト: encukou/beets
            val = re.match(r'[\+-]?[0-9\.]*', val.strip()).group(0)
            if not val:
                return 0.0
            else:
                return float(val)

    else:
        return val


# Flags for encoding field behavior.

# Determine style of packing, if any.
packing = enum(
    'SLASHED',  # pair delimited by /
    'TUPLE',  # a python tuple of 2 items
    'DATE',  # YYYY-MM-DD
    name='packing')


class StorageStyle(object):
    """Parameterizes the storage behavior of a single field for a
    certain tag format.
     - key: The Mutagen key used to access the field's data.
     - list_elem: Store item as a single object or as first element
       of a list.
     - as_type: Which type the value is stored as (unicode, int,
       bool, or str).
     - packing: If this value is packed in a multiple-value storage
       unit, which type of packing (in the packing enum). Otherwise,
       None. (Makes as_type irrelevant).
コード例 #6
0
# Reduced weights for certain portions of the string.
SD_PATTERNS = [
    (r'^the ', 0.1),
    (r'[\[\(]?(ep|single)[\]\)]?', 0.0),
    (r'[\[\(]?(featuring|feat|ft)[\. :].+', 0.1),
    (r'\(.*?\)', 0.3),
    (r'\[.*?\]', 0.3),
    (r'(, )?(pt\.|part) .+', 0.2),
]
# Replacements to use before testing distance.
SD_REPLACE = [
    (r'&', 'and'),
]

# Recommendation enumeration.
recommendation = enum('none', 'low', 'medium', 'strong', name='recommendation')

# Artist signals that indicate "various artists". These are used at the
# album level to determine whether a given release is likely a VA
# release and also on the track level to to remove the penalty for
# differing artists.
VA_ARTISTS = (u'', u'various artists', u'various', u'va', u'unknown')

# Global logger.
log = logging.getLogger('beets')


# Primary matching functionality.

def _string_dist_basic(str1, str2):
    """Basic edit distance between two strings, ignoring
コード例 #7
0
ファイル: mediafile.py プロジェクト: Boehemyth/beets
    g1 = min(round((10 ** (gain / -10)) * 1000), 65534)
    # Same as above, except our reference level is 2500 units.
    g2 = min(round((10 ** (gain / -10)) * 2500), 65534)

    # The purpose of these values are unknown, but they also seem to be
    # unused so we just use zero.
    uk = 0
    values = (g1, g1, g2, g2, uk, uk, peak, peak, uk, uk)
    return (u' %08X' * 10) % values



# Flags for encoding field behavior.

# Determine style of packing, if any.
packing = enum('SC',        # Sound Check gain/peak encoding
               name='packing')



# StorageStyle classes describe strategies for accessing values in
# Mutagen file objects.

class StorageStyle(object):
    """Parameterizes the storage behavior of a single field for a
    certain tag format.
     - key: The Mutagen key used to access the field's data.
     - as_type: Which type the value is stored as (unicode, int,
       bool, or str).
     - packing: If this value is packed in a multiple-value storage
       unit, which type of packing (in the packing enum). Otherwise,
       None. (Makes as_type irrelevant).
コード例 #8
0
ファイル: mediafile.py プロジェクト: Lugoues/beets
    # Same as above, except our reference level is 2500 units.
    g2 = min(round((10**(gain / -10)) * 2500), 65534)

    # The purpose of these values are unknown, but they also seem to be
    # unused so we just use zero.
    uk = 0
    values = (g1, g1, g2, g2, uk, uk, peak, peak, uk, uk)
    return (u' %08X' * 10) % values


# Flags for encoding field behavior.

# Determine style of packing, if any.
packing = enum(
    'SLASHED',  # pair delimited by /
    'TUPLE',  # a python tuple of 2 items
    'DATE',  # YYYY-MM-DD
    'SC',  # Sound Check gain/peak encoding
    name='packing')


class StorageStyle(object):
    """Parameterizes the storage behavior of a single field for a
    certain tag format.
     - key: The Mutagen key used to access the field's data.
     - list_elem: Store item as a single object or as first element
       of a list.
     - as_type: Which type the value is stored as (unicode, int,
       bool, or str).
     - packing: If this value is packed in a multiple-value storage
       unit, which type of packing (in the packing enum). Otherwise,
       None. (Makes as_type irrelevant).
コード例 #9
0
ファイル: mediafile.py プロジェクト: phmongeau/beets
    g2 = min(round((10 ** (gain / -10)) * 2500), 65534)

    # The purpose of these values are unknown, but they also seem to be
    # unused so we just use zero.
    uk = 0
    values = (g1, g1, g2, g2, uk, uk, peak, peak, uk, uk)
    return (u" %08X" * 10) % values


# Flags for encoding field behavior.

# Determine style of packing, if any.
packing = enum(
    "SLASHED",  # pair delimited by /
    "TUPLE",  # a python tuple of 2 items
    "DATE",  # YYYY-MM-DD
    "SC",  # Sound Check gain/peak encoding
    name="packing",
)


class StorageStyle(object):
    """Parameterizes the storage behavior of a single field for a
    certain tag format.
     - key: The Mutagen key used to access the field's data.
     - list_elem: Store item as a single object or as first element
       of a list.
     - as_type: Which type the value is stored as (unicode, int,
       bool, or str).
     - packing: If this value is packed in a multiple-value storage
       unit, which type of packing (in the packing enum). Otherwise,
コード例 #10
0
ファイル: match.py プロジェクト: Lugoues/beets
# Words that can be moved to the end of a string using a comma.
SD_END_WORDS = ["the", "a", "an"]
# Reduced weights for certain portions of the string.
SD_PATTERNS = [
    (r"^the ", 0.1),
    (r"[\[\(]?(ep|single)[\]\)]?", 0.0),
    (r"[\[\(]?(featuring|feat|ft)[\. :].+", 0.1),
    (r"\(.*?\)", 0.3),
    (r"\[.*?\]", 0.3),
    (r"(, )?(pt\.|part) .+", 0.2),
]
# Replacements to use before testing distance.
SD_REPLACE = [(r"&", "and")]

# Recommendation enumeration.
recommendation = enum("none", "low", "medium", "strong", name="recommendation")

# Artist signals that indicate "various artists". These are used at the
# album level to determine whether a given release is likely a VA
# release and also on the track level to to remove the penalty for
# differing artists.
VA_ARTISTS = (u"", u"various artists", u"va", u"unknown")

# Global logger.
log = logging.getLogger("beets")


# Primary matching functionality.


def _string_dist_basic(str1, str2):
コード例 #11
0
ファイル: mediafile.py プロジェクト: agrausem/beets
    # Same as above, except our reference level is 2500 units.
    g2 = min(round((10 ** (gain / -10)) * 2500), 65534)

    # The purpose of these values are unknown, but they also seem to be
    # unused so we just use zero.
    uk = 0
    values = (g1, g1, g2, g2, uk, uk, peak, peak, uk, uk)
    return (u' %08X' * 10) % values


# Flags for encoding field behavior.

# Determine style of packing, if any.
packing = enum('SLASHED',   # pair delimited by /
               'TUPLE',     # a python tuple of 2 items
               'DATE',      # YYYY-MM-DD
               'SC',        # Sound Check gain/peak encoding
               name='packing')

class StorageStyle(object):
    """Parameterizes the storage behavior of a single field for a
    certain tag format.
     - key: The Mutagen key used to access the field's data.
     - list_elem: Store item as a single object or as first element
       of a list.
     - as_type: Which type the value is stored as (unicode, int,
       bool, or str).
     - packing: If this value is packed in a multiple-value storage
       unit, which type of packing (in the packing enum). Otherwise,
       None. (Makes as_type irrelevant).
     - pack_pos: If the value is packed, in which position it is
コード例 #12
0
ファイル: importer.py プロジェクト: asutherland/beets
import pickle
import itertools
from collections import defaultdict

from beets import autotag
from beets import library
from beets import dbcore
from beets import plugins
from beets import util
from beets import config
from beets.util import pipeline
from beets.util import syspath, normpath, displayable_path
from beets.util.enumeration import enum
from beets import mediafile

action = enum("SKIP", "ASIS", "TRACKS", "MANUAL", "APPLY", "MANUAL_ID", "ALBUMS", name="action")

QUEUE_SIZE = 128
SINGLE_ARTIST_THRESH = 0.25
VARIOUS_ARTISTS = u"Various Artists"

# Global logger.
log = logging.getLogger("beets")


class ImportAbort(Exception):
    """Raised when the user aborts the tagging operation.
    """

    pass
コード例 #13
0
ファイル: mediafile.py プロジェクト: pombredanne/beets
                val = unicode(val)
            val = re.match(r"[\+-]?[0-9\.]*", val.strip()).group(0)
            if not val:
                return 0.0
            else:
                return float(val)

    else:
        return val


# Flags for encoding field behavior.

# Determine style of packing, if any.
packing = enum(
    "SLASHED", "TUPLE", "DATE", name="packing"  # pair delimited by /  # a python tuple of 2 items  # YYYY-MM-DD
)


class StorageStyle(object):
    """Parameterizes the storage behavior of a single field for a
    certain tag format.
     - key: The Mutagen key used to access the field's data.
     - list_elem: Store item as a single object or as first element
       of a list.
     - as_type: Which type the value is stored as (unicode, int,
       bool, or str).
     - packing: If this value is packed in a multiple-value storage
       unit, which type of packing (in the packing enum). Otherwise,
       None. (Makes as_type irrelevant).
     - pack_pos: If the value is packed, in which position it is