remove API keys
add display current download page
This commit is contained in:
Alexander Popov 2019-08-30 00:29:25 +03:00
parent 70c9e3dc71
commit 3a0e5011df
5 changed files with 20 additions and 18 deletions

3
.gitignore vendored
View File

@ -1,2 +1,5 @@
*.json *.json
*.pyc *.pyc
build/
dist/
*.egg-info/

View File

@ -1,6 +1,6 @@
![Version](https://img.shields.io/pypi/v/lastfm-backup.svg?style=flat-square) ![Version](https://img.shields.io/pypi/v/lastfm-backup.svg?style=flat-square)
![License](https://img.shields.io/pypi/l/lastfm-backup.svg.svg?style=flat-square) ![License](https://img.shields.io/pypi/l/lastfm-backup.svg?style=flat-square)
![PyVersion](https://img.shields.io/pypi/pyversions/lastfm-backup.svg.svg?style=flat-square) ![PyVersion](https://img.shields.io/pypi/pyversions/lastfm-backup.svg?style=flat-square)
**How to use:** **How to use:**
-------------- --------------
@ -8,10 +8,7 @@
* Stop scrobbling! * Stop scrobbling!
* Rename `config.json.example` to `config.json` and edit. * Rename `config.json.example` to `config.json` and edit.
* Run script `lastfm_backup.py`. * Run script `lastfm_backup.py`.
* WAIT!! * WAIT =)
My `>72,2k` tracks scrobbles sized `~9.9M`.
Tar.xz sized `5.4K`.
**TODO:** **TODO:**
-------- --------
@ -19,4 +16,4 @@ Tar.xz sized `5.4K`.
- [ ] more output types (sqlite, csv) - [ ] more output types (sqlite, csv)
- [ ] confirugurabled output - [ ] confirugurabled output
- [ ] continue backup - [ ] continue backup
- [ ] multithread - [ ] multithreading

View File

@ -5,7 +5,7 @@ import urllib.request
import os.path import os.path
__author__ = 'Alexander Popov' __author__ = 'Alexander Popov'
__version__ = '1.0.0' __version__ = '1.0.1'
__license__ = 'Unlicense' __license__ = 'Unlicense'
@ -42,7 +42,7 @@ if __name__ == '__main__':
curPage = 1 curPage = 1
tracks = [] tracks = []
while curPage <= PAGES: while curPage <= PAGES:
print('\r%d%%' % (curPage * 100 / PAGES), end='') print('\r{0}% [{1} of {2}]'.format((curPage * 100 / PAGES), curPage, PAGES), end='')
response = get_scrobbles(CFG['username'], CFG['api_key'], curPage) response = get_scrobbles(CFG['username'], CFG['api_key'], curPage)
for track in response: for track in response:
@ -57,5 +57,5 @@ if __name__ == '__main__':
f.write( f.write(
json.dumps(tracks, indent=4, sort_keys=True, ensure_ascii=False)) json.dumps(tracks, indent=4, sort_keys=True, ensure_ascii=False))
print('\r{0} tracks saved in {1}.json!'.format( print('\n{0} tracks saved in {1}.json!'.format(
len(tracks), CFG['username'],)) len(tracks), CFG['username'],))

8
samples/getTracks.py Normal file → Executable file
View File

@ -2,14 +2,18 @@
import lastfm_backup as lfm import lastfm_backup as lfm
API_KEY = '0e5070361556658180f9b1518b341eda' API_KEY = '0'
USERNAME = 'goodgame' USERNAME = 'admin'
if __name__ == '__main__': if __name__ == '__main__':
pages = lfm.get_pages(USERNAME, API_KEY) pages = lfm.get_pages(USERNAME, API_KEY)
count = 0
for page in range(1, pages + 1): for page in range(1, pages + 1):
tracks = lfm.get_scrobbles(USERNAME, API_KEY, page) tracks = lfm.get_scrobbles(USERNAME, API_KEY, page)
for track in tracks: for track in tracks:
print('%s - %s' % (track['artist']['#text'], track['name'],)) print('%s - %s' % (track['artist']['#text'], track['name'],))
count = count + 1
print('\nTotal scrobbling tracks: %d' % count)

View File

@ -1,8 +1,8 @@
from distutils.core import setup import setuptools
import lastfm_backup import lastfm_backup
setup( setuptools.setup(
name='lastfm-backup', name='lastfm-backup',
version=lastfm_backup.__version__, version=lastfm_backup.__version__,
description='Last.fm scrobbles backup', description='Last.fm scrobbles backup',
@ -16,8 +16,6 @@ setup(
keywords=['last.fm', 'lastfm', 'backup'], keywords=['last.fm', 'lastfm', 'backup'],
classifiers=['License :: Public Domain', classifiers=['License :: Public Domain',
'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2', 'Operating System :: OS Independent'],
'Programming Language :: Python :: 3.3', python_requires='>=3.0'
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5'],
) )