Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 837e1280bd | |||
| 8f9c825903 |
@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "vrobbler"
|
name = "vrobbler"
|
||||||
version = "0.8.2"
|
version = "0.8.3"
|
||||||
description = ""
|
description = ""
|
||||||
authors = ["Colin Powell <colin@unbl.ink>"]
|
authors = ["Colin Powell <colin@unbl.ink>"]
|
||||||
|
|
||||||
|
|||||||
@ -52,7 +52,9 @@ class AudioScrobblerTSVImport(TimeStampedModel):
|
|||||||
tz = None
|
tz = None
|
||||||
if self.user:
|
if self.user:
|
||||||
tz = self.user.profile.tzinfo
|
tz = self.user.profile.tzinfo
|
||||||
scrobbles = process_audioscrobbler_tsv_file(self.tsv_file.path, tz=tz)
|
scrobbles = process_audioscrobbler_tsv_file(
|
||||||
|
self.tsv_file.path, user_tz=tz
|
||||||
|
)
|
||||||
if scrobbles:
|
if scrobbles:
|
||||||
self.process_log = f"Created {len(scrobbles)} scrobbles"
|
self.process_log = f"Created {len(scrobbles)} scrobbles"
|
||||||
for scrobble in scrobbles:
|
for scrobble in scrobbles:
|
||||||
|
|||||||
@ -9,11 +9,11 @@ from scrobbles.models import Scrobble
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def process_audioscrobbler_tsv_file(file_path, tz=None):
|
def process_audioscrobbler_tsv_file(file_path, user_tz=None):
|
||||||
"""Takes a path to a file of TSV data and imports it as past scrobbles"""
|
"""Takes a path to a file of TSV data and imports it as past scrobbles"""
|
||||||
new_scrobbles = []
|
new_scrobbles = []
|
||||||
if not tz:
|
if not user_tz:
|
||||||
tz = pytz.utc
|
user_tz = pytz.utc
|
||||||
|
|
||||||
with open(file_path) as infile:
|
with open(file_path) as infile:
|
||||||
source = 'Audioscrobbler File'
|
source = 'Audioscrobbler File'
|
||||||
@ -71,8 +71,10 @@ def process_audioscrobbler_tsv_file(file_path, tz=None):
|
|||||||
track.musicbrainz_id = row[7]
|
track.musicbrainz_id = row[7]
|
||||||
track.save()
|
track.save()
|
||||||
|
|
||||||
timestamp = datetime.utcfromtimestamp(int(row[6])).replace(
|
timestamp = (
|
||||||
tzinfo=tz
|
datetime.utcfromtimestamp(int(row[6]))
|
||||||
|
.replace(tzinfo=user_tz)
|
||||||
|
.astimezone(pytz.utc)
|
||||||
)
|
)
|
||||||
source = 'Audioscrobbler File'
|
source = 'Audioscrobbler File'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user