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

Drop whipper caching #336

Merged
merged 6 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ MEDIUM

- retry cdrdao a few times when it had to load the tray

- getting cache results should depend on same drive/offset

- do some character mangling so trail of dead is not in a hidden dir

HARD
Expand Down
5 changes: 0 additions & 5 deletions whipper/command/cd.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def do(self):
self.ittoc = self.program.getFastToc(self.runner, self.device)

# already show us some info based on this
self.program.getRipResult(self.ittoc.getCDDBDiscId())
print("CDDB disc id: %s" % self.ittoc.getCDDBDiscId())
self.mbdiscid = self.ittoc.getMusicBrainzDiscId()
print("MusicBrainz disc id %s" % self.mbdiscid)
Expand Down Expand Up @@ -499,8 +498,6 @@ def _ripIfNotRipped(number):
self.itable.setFile(number, 1, trackResult.filename,
self.itable.getTrackLength(number), number)

self.program.saveRipResult()

# check for hidden track one audio
htoa = self.program.getHTOA()
if htoa:
Expand Down Expand Up @@ -541,8 +538,6 @@ def _ripIfNotRipped(number):

accurip.print_report(self.program.result)

self.program.saveRipResult()

self.program.writeLog(discName, self.logger)


Expand Down
29 changes: 2 additions & 27 deletions whipper/common/accurip.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,16 @@

import struct
import whipper
from os import makedirs
from os.path import dirname, exists, join
from urllib.error import URLError, HTTPError
from urllib.request import urlopen, Request

from whipper.common import directory
from whipper.program.arc import accuraterip_checksum

import logging
logger = logging.getLogger(__name__)


ACCURATERIP_URL = "http://www.accuraterip.com/accuraterip/"
_CACHE_DIR = join(directory.cache_path(), 'accurip')


class EntryNotFound(Exception):
Expand Down Expand Up @@ -142,34 +138,13 @@ def _download_entry(path):
logger.error('error retrieving AccurateRip entry: %s', e)


def _save_entry(raw_entry, path):
logger.debug('saving AccurateRip entry to %s', path)
try:
makedirs(dirname(path), exist_ok=True)
except OSError as e:
logger.error('could not save entry to %s: %s', path, e)
return
with open(path, 'wb') as f:
f.write(raw_entry)


def get_db_entry(path):
"""
Retrieve cached AccurateRip disc entry as array of _AccurateRipResponses.

Downloads entry from accuraterip.com on cache fault.
Download entry from accuraterip.com.

``path`` is in the format of the output of ``table.accuraterip_path()``.
"""
cached_path = join(_CACHE_DIR, path)
if exists(cached_path):
logger.debug('found accuraterip entry at %s', cached_path)
with open(cached_path, 'rb') as f:
raw_entry = f.read()
else:
raw_entry = _download_entry(path)
if raw_entry:
_save_entry(raw_entry, cached_path)
raw_entry = _download_entry(path)
if not raw_entry:
logger.warning('entry not found in AccurateRip database')
raise EntryNotFound
Expand Down
218 changes: 0 additions & 218 deletions whipper/common/cache.py

This file was deleted.

9 changes: 0 additions & 9 deletions whipper/common/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ def config_path():
return join(path, 'whipper.conf')


def cache_path(name=None):
path = join(getenv('XDG_CACHE_HOME') or join(expanduser('~'), '.cache'),
'whipper')
if name:
path = join(path, name)
makedirs(path, exist_ok=True)
return path


def data_path(name=None):
path = join(getenv('XDG_DATA_HOME') or
join(expanduser('~'), '.local/share'),
Expand Down
Loading