{"id":13572435,"url":"https://github.com/pylast/pylast","last_synced_at":"2025-10-20T16:20:58.974Z","repository":{"id":6561253,"uuid":"7803088","full_name":"pylast/pylast","owner":"pylast","description":"A Python interface to Last.fm and Libre.fm","archived":false,"fork":false,"pushed_at":"2024-05-22T19:56:09.000Z","size":1595,"stargazers_count":653,"open_issues_count":16,"forks_count":108,"subscribers_count":19,"default_branch":"main","last_synced_at":"2024-05-22T20:04:56.562Z","etag":null,"topics":["hacktoberfest","last-fm","lastfm","libre","libre-fm","librefm","music","pylast","python","scrobble","scrobbler","scrobbling"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/pylast/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pylast.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"hugovk"}},"created_at":"2013-01-24T17:21:07.000Z","updated_at":"2024-06-18T12:28:15.926Z","dependencies_parsed_at":"2023-02-15T22:30:42.275Z","dependency_job_id":"20adf605-3a07-4761-925d-7d3ef4c3f3d7","html_url":"https://github.com/pylast/pylast","commit_stats":{"total_commits":844,"total_committers":39,"mean_commits":"21.641025641025642","dds":0.2819905213270142,"last_synced_commit":"8d8263ce42b4dfeec282eaea432e18d8007d0e5c"},"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pylast%2Fpylast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pylast%2Fpylast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pylast%2Fpylast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pylast%2Fpylast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pylast","download_url":"https://codeload.github.com/pylast/pylast/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247160157,"owners_count":20893777,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","last-fm","lastfm","libre","libre-fm","librefm","music","pylast","python","scrobble","scrobbler","scrobbling"],"created_at":"2024-08-01T14:01:23.153Z","updated_at":"2025-10-20T16:20:58.968Z","avatar_url":"https://github.com/pylast.png","language":"Python","funding_links":["https://github.com/sponsors/hugovk"],"categories":["Python"],"sub_categories":[],"readme":"# pyLast\n\n[![PyPI version](https://img.shields.io/pypi/v/pylast.svg?logo=pypi\u0026logoColor=FFE873)](https://pypi.org/project/pylast/)\n[![Supported Python versions](https://img.shields.io/pypi/pyversions/pylast.svg?logo=python\u0026logoColor=FFE873)](https://pypi.org/project/pylast/)\n[![PyPI downloads](https://img.shields.io/pypi/dm/pylast.svg)](https://pypistats.org/packages/pylast)\n[![GitHub Actions status](https://github.com/pylast/pylast/workflows/Test/badge.svg)](https://github.com/pylast/pylast/actions)\n[![Codecov](https://codecov.io/gh/pylast/pylast/branch/main/graph/badge.svg)](https://codecov.io/gh/pylast/pylast)\n[![Licence](https://img.shields.io/github/license/pylast/pylast.svg)](LICENSE.txt)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.11247604.svg)](https://doi.org/10.5281/zenodo.11247604)\n[![Code style: Black](https://img.shields.io/badge/code%20style-Black-000000.svg)](https://github.com/psf/black)\n\nA Python interface to [Last.fm](https://www.last.fm/) and other API-compatible websites\nsuch as [Libre.fm](https://libre.fm/).\n\nUse the pydoc utility for help on usage or see [tests/](tests/) for examples.\n\n## Installation\n\nInstall via pip:\n\n```sh\npython3 -m pip install pylast\n```\n\nInstall latest development version:\n\n```sh\npython3 -m pip install -U git+https://github.com/pylast/pylast\n```\n\nOr from requirements.txt:\n\n```txt\n-e https://github.com/pylast/pylast.git#egg=pylast\n```\n\n## Features\n\n- Simple public interface.\n- Access to all the data exposed by the Last.fm web services.\n- Scrobbling support.\n- Full object-oriented design.\n- Proxy support.\n- Internal caching support for some web services calls (disabled by default).\n- Support for other API-compatible networks like Libre.fm.\n\n## Getting started\n\nHere's some simple code example to get you started. In order to create any object from\npyLast, you need a `Network` object which represents a social music network that is\nLast.fm or any other API-compatible one. You can obtain a pre-configured one for Last.fm\nand use it as follows:\n\n```python\nimport pylast\n\n# You have to have your own unique two values for API_KEY and API_SECRET\n# Obtain yours from https://www.last.fm/api/account/create for Last.fm\nAPI_KEY = \"b25b959554ed76058ac220b7b2e0a026\"  # this is a sample key\nAPI_SECRET = \"425b55975eed76058ac220b7b4e8a054\"\n\n# In order to perform a write operation you need to authenticate yourself\nusername = \"your_user_name\"\npassword_hash = pylast.md5(\"your_password\")\n\nnetwork = pylast.LastFMNetwork(\n    api_key=API_KEY,\n    api_secret=API_SECRET,\n    username=username,\n    password_hash=password_hash,\n)\n```\n\nAlternatively, instead of creating `network` with a username and password, you can\nauthenticate with a session key:\n\n```python\nimport pylast\n\nSESSION_KEY_FILE = os.path.join(os.path.expanduser(\"~\"), \".session_key\")\nnetwork = pylast.LastFMNetwork(API_KEY, API_SECRET)\nif not os.path.exists(SESSION_KEY_FILE):\n    skg = pylast.SessionKeyGenerator(network)\n    url = skg.get_web_auth_url()\n\n    print(f\"Please authorize this script to access your account: {url}\\n\")\n    import time\n    import webbrowser\n\n    webbrowser.open(url)\n\n    while True:\n        try:\n            session_key = skg.get_web_auth_session_key(url)\n            with open(SESSION_KEY_FILE, \"w\") as f:\n                f.write(session_key)\n            break\n        except pylast.WSError:\n            time.sleep(1)\nelse:\n    session_key = open(SESSION_KEY_FILE).read()\n\nnetwork.session_key = session_key\n```\n\nAnd away we go:\n\n```python\n# Now you can use that object everywhere\ntrack = network.get_track(\"Iron Maiden\", \"The Nomad\")\ntrack.love()\ntrack.add_tags((\"awesome\", \"favorite\"))\n\n# Type help(pylast.LastFMNetwork) or help(pylast) in a Python interpreter\n# to get more help about anything and see examples of how it works\n```\n\nMore examples in\n\u003ca href=\"https://github.com/hugovk/lastfm-tools\"\u003ehugovk/lastfm-tools\u003c/a\u003e and\n[tests/](https://github.com/pylast/pylast/tree/main/tests).\n\n## Testing\n\nThe [tests/](https://github.com/pylast/pylast/tree/main/tests) directory contains\nintegration and unit tests with Last.fm, and plenty of code examples.\n\nFor integration tests you need a test account at Last.fm that will become cluttered with\ntest data, and an API key and secret. Either copy\n[example_test_pylast.yaml](https://github.com/pylast/pylast/blob/main/example_test_pylast.yaml)\nto test_pylast.yaml and fill out the credentials, or set them as environment variables\nlike:\n\n```sh\nexport PYLAST_USERNAME=TODO_ENTER_YOURS_HERE\nexport PYLAST_PASSWORD_HASH=TODO_ENTER_YOURS_HERE\nexport PYLAST_API_KEY=TODO_ENTER_YOURS_HERE\nexport PYLAST_API_SECRET=TODO_ENTER_YOURS_HERE\n```\n\nTo run all unit and integration tests:\n\n```sh\npython3 -m pip install -e \".[tests]\"\npytest\n```\n\nOr run just one test case:\n\n```sh\npytest -k test_scrobble\n```\n\nTo run with coverage:\n\n```sh\npytest -v --cov pylast --cov-report term-missing\ncoverage report # for command-line report\ncoverage html   # for HTML report\nopen htmlcov/index.html\n```\n\n## Logging\n\nTo enable from your own code:\n\n```python\nimport logging\nimport pylast\n\nlogging.basicConfig(level=logging.INFO)\n\n\nnetwork = pylast.LastFMNetwork(...)\n```\n\nTo enable from pytest:\n\n```sh\npytest --log-cli-level info -k test_album_search_images\n```\n\nTo also see data returned from the API, use `level=logging.DEBUG` or\n`--log-cli-level debug` instead.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpylast%2Fpylast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpylast%2Fpylast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpylast%2Fpylast/lists"}