Skip to content

Commit

Permalink
Big Update of posts
Browse files Browse the repository at this point in the history
  • Loading branch information
russmckendrick committed May 5, 2024
1 parent 4b67b45 commit 6ab523c
Show file tree
Hide file tree
Showing 76 changed files with 1,424 additions and 279 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Title": "Mary Star of the Sea"}
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
298 changes: 258 additions & 40 deletions content/tunes/2024-04-01-listened-to-this-week/index.md

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Title": "Homegrown"}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Title": "Mellon Collie and the Infinite Sadness (Remastered)"}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Title": "Quadrophenia (2013 Remaster)"}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified content/tunes/2024-04-08-listened-to-this-week/artists/Dodgy.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified content/tunes/2024-04-08-listened-to-this-week/artists/INXS.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
349 changes: 315 additions & 34 deletions content/tunes/2024-04-08-listened-to-this-week/index.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Title": "...And Out Come the Wolves"}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"Title": "Gish"
}
{"Title": "Gish"}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"Title": "God-Fodder"
}
{"Title": "God Fodder"}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"Title": "Mental-Notes"
}
{"Title": "Mental Notes"}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"Title": "Schubert-Dip"
}
{"Title": "Schubert Dip"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Title": "Set Yourself on Fire"}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"Title": "Stacked-Up"
}
{"Title": "Stacked Up"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Title": "The Southern Harmony and Musical Companion"}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"Title": "Too-Much-Pressure"
}
{"Title": "Too Much Pressure"}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"Title": "Twisted"
}
{"Title": "Twisted"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Title": "Who Cares a Lot? The Greatest Hits"}

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"Title": "Del-Amitri"
}
{"Title": "Del Amitri"}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"Title": "EMF"
}
{"Title": "EMF"}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"Title": "Faith-No-More"
}
{"Title": "Faith No More"}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Title": "Ned's Atomic Dustbin"}
Diff not rendered.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"Title": "Rancid"
}
{"Title": "Rancid"}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"Title": "Senser"
}
{"Title": "Senser"}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"Title": "Split-Enz"
}
{"Title": "Split Enz"}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"Title": "Stars"
}
{"Title": "Stars"}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"Title": "The-Black-Crowes"
}
{"Title": "The Black Crowes"}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"Title": "The-Selecter"
}
{"Title": "The Selecter"}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"Title": "The-Smashing-Pumpkins"
}
{"Title": "The Smashing Pumpkins"}
Diff not rendered.

This file was deleted.

357 changes: 312 additions & 45 deletions content/tunes/2024-04-15-listened-to-this-week/index.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Title": "Duran Duran (Deluxe Edition)"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Title": "Hounds of Love (2018 Remaster)"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Title": "In Time: The Best of R.E.M. 1988-2003"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Title": "Violator (Deluxe)"}
Diff not rendered.

This file was deleted.

368 changes: 325 additions & 43 deletions content/tunes/2024-04-22-listened-to-this-week/index.md

Large diffs are not rendered by default.

189 changes: 163 additions & 26 deletions content/tunes/2024-04-29-listened-to-this-week/index.md

Large diffs are not rendered by default.

33 changes: 18 additions & 15 deletions generate_blog_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ def get_lastfm_data(method, lastfm_user, lastfm_api_key, from_time, to_time):
response = requests.get(url)
return response.json()

import os
import json
import time
import requests
def clean_output(text):
# Remove backticks, double quotes, and any non-word, non-whitespace, or non-hyphen characters
return re.sub(r'[\'"]', '', text)

def get_collection_data(collection_url):
"""Get collection data from a personal website."""
Expand Down Expand Up @@ -117,10 +116,15 @@ def generate_summary(artist_data, album_data, collection_info):
top_albums[(artist_name, album_name)] += int(album['playcount'])
return top_artists.most_common(12), top_albums.most_common(12), collection_info

# Define the custom filter function
def regex_replace(value, pattern, replacement=""):
return re.sub(pattern, replacement, value)

def render_template(template_name, context):
"""Render a template using Jinja2."""
env = Environment(loader=FileSystemLoader('.'))
template = env.get_template(template_name)
env.filters['regex_replace'] = regex_replace
return template.render(context)

def download_image(url, folder, name):
Expand Down Expand Up @@ -175,15 +179,15 @@ def generate_title_and_summary(date_str_start, week_number, top_artists, top_alb
"""Generate a title and summary for the blog post using CrewAI."""
title_agent = Agent(
role="Title Generator",
goal=f"Generate a catchy and SEO-friendly title for a weekly music blog post. The post is about the top artists and albums listened to this week, {', '.join([artist for artist, _ in top_artists])} and top albums: {', '.join([album for (_, album), _ in top_albums])}.",
backstory="You are an expert in creating engaging and SEO-optimized titles for blog posts. Your titles should grab the reader's attention and include relevant keywords.",
goal=f"Generate a catchy and SEO-friendly title for a weekly music blog post. The post is about the top artists and albums listened to this week, {', '.join([artist for artist, _ in top_artists])} and top albums: {', '.join([album for (_, album), _ in top_albums])}. Do not exceed 70 characters or use special characters such a :, -, |, quotes or emojis.",
backstory="You are an expert in creating creative, engaging and SEO-optimized titles for blog posts. Your titles should grab the reader's attention and include relevant keywords.",
verbose=True,
max_inter=1,
)

title_task = Task(
description=f"Generate a title for a weekly music blog post featuring the top artists: {', '.join([artist for artist, _ in top_artists])} and top albums: {', '.join([album for (_, album), _ in top_albums])}.",
expected_output="A catchy and SEO-friendly title for the blog post. Do not exceed 70 characters or use special characters such a :, -, |, or emojis.",
expected_output="A catchy and SEO-friendly title for the blog post. Do not exceed 70 characters or use special characters such a :, -, |, quotes or emojis.",
max_inter=1,
tools=[],
agent=title_agent,
Expand All @@ -199,7 +203,7 @@ def generate_title_and_summary(date_str_start, week_number, top_artists, top_alb

summary_task = Task(
description=f"Generate a summary for a weekly music blog post featuring the top artists: {', '.join([artist for artist, _ in top_artists])} and top albums: {', '.join([album for (_, album), _ in top_albums])}.",
expected_output="A concise and SEO-friendly summary for the blog post. It shoud be no more than 180 characters.",
expected_output="A concise and SEO-friendly summary for the blog post. It shouldn't be more than 180 characters and it should NOT use special characters such a :, -, |, quotes or emojis.",
max_inter=1,
tools=[],
agent=summary_agent,
Expand All @@ -213,21 +217,20 @@ def generate_title_and_summary(date_str_start, week_number, top_artists, top_alb
)

result = crew.kickoff()
title = re.sub(r'[^\w\s-]', '', result['tasks_outputs'][0].exported_output)
print("Crew.kickoff() result:")
print(result)
print()

title = clean_output(result['tasks_outputs'][0].exported_output)
print("Title:")
print(result['tasks_outputs'][0].exported_output)
print(title)
print()


summary = clean_output(result['tasks_outputs'][1].exported_output)
print("Summary:")
print(result['tasks_outputs'][1].exported_output)
print(summary)
print()

title = result['tasks_outputs'][0].exported_output
summary = result['tasks_outputs'][1].exported_output

return title, summary

def generate_blog_post(top_artists, top_albums, collection_info, week_start, week_end):
Expand Down
6 changes: 3 additions & 3 deletions lastfm-post-template.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: {{ title }}
title: "{{ title }}"
author: "Russ McKendrick"
date: "{{ date }}"
description: "{{ summary }}"
Expand All @@ -16,7 +16,7 @@ tags:
This is what GPT had to say this about what I listened to last week; it is auto-generated and might not be 💯% factual.
{% raw %}{{< /notice >}}{% endraw %}

{% raw %}{{< gallery match="artists/*" sortOrder="desc" rowHeight="150" margins="5" thumbnailResizeOptions="600x600 q90 Lanczos" showExif=true previewType="blur" embedPreview=true loadJQuery=true >}}{% endraw %}
{% raw %}{{< gallery match="artists/*" sortOrder="desc" rowHeight="250" margins="5" thumbnailResizeOptions="600x600 q90 Lanczos" showExif=true previewType="blur" embedPreview=true loadJQuery=true >}}{% endraw %}

{{ blog_post }}

Expand All @@ -40,4 +40,4 @@ This is what GPT had to say this about what I listened to last week; it is auto-
{% endif %}
{%- endfor %}

{% raw %}{{< gallery match="albums/*" sortOrder="desc" rowHeight="150" margins="5" thumbnailResizeOptions="600x600 q90 Lanczos" showExif=true previewType="blur" embedPreview=true loadJQuery=flase >}}{% endraw %}
{% raw %}{{< gallery match="albums/*" sortOrder="desc" rowHeight="200" margins="5" thumbnailResizeOptions="600x600 q90 Lanczos" showExif=true previewType="blur" embedPreview=true loadJQuery=flase >}}{% endraw %}

0 comments on commit 6ab523c

Please sign in to comment.