Make alternative clearer via own code blocks
@@ -84,8 +84,12 @@ network = pylast.LastFMNetwork(
username=username,
password_hash=password_hash,
)
+```
+
+Alternatively, instead of creating `network` with a username and password,
+you can authenticate with a session key:
-# You can also authenticate with a session key
+```python
SESSION_KEY_FILE = os.path.join(os.path.expanduser("~"), ".session_key")
network = pylast.LastFMNetwork(API_KEY, API_SECRET)
if not os.path.exists(SESSION_KEY_FILE):
@@ -110,7 +114,11 @@ else:
session_key = open(SESSION_KEY_FILE).read()
network.session_key = session_key
+```
+And away we go:
+
+```python
# Now you can use that object everywhere
track = network.get_track("Iron Maiden", "The Nomad")
track.love()
@@ -120,6 +128,7 @@ track.add_tags(("awesome", "favorite"))
# to get more help about anything and see examples of how it works
```
+
More examples in
<a href="https://github.com/hugovk/lastfm-tools">hugovk/lastfm-tools</a> and
[tests/](https://github.com/pylast/pylast/tree/main/tests).
