import feedparser
import requests
from bs4 import BeautifulSoup
import time

# Enter the bandcamp URL of the artist you want to track
bandcamp_url = 'https://artistname.bandcamp.com/'

# Enter the URL for the RSS feed service you are going to use to receive updates
rss_feed_url = 'https://www.example.com/rss'

# Define the headers for the requests
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'}

# Initialize the parser
d = feedparser.FeedParserDict()

# Get the links for the music from the Bandcamp page
def get_links_from_page(url):
    response = requests.get(url, headers=headers)
    soup = BeautifulSoup(response.text, 'html.parser')
    href_list = []
    for a in soup.find_all('a', href=True):
        if '/track/' in a['href']:
            href_list.append('https://'+a['href'][2:])
    return href_list

# Process the links and format them into RSS items
def process_links(href_list):
    items_content = ''
    for href in href_list:
        name = href.split('/')[-1].replace('-', ' ').title()
        items_content += f'<item><title>New Music from {name}</title><link>{href}</link><description>New music released by {name}. Check it out!</description></item>'
    return items_content

# Loop through and update for new content
while True:
    href_list = get_links_from_page(bandcamp_url)
    if not d.entries:
        for href in href_list:
            d.entries.append({'title': href.split('/')[-1].replace('-', ' ').title(), 'link': href})
        items_content = process_links(href_list)
        rss_content = f'''<?xml version="1.0" encoding="UTF-8"?>
        <rss version="2.0">
            <channel>
                <title>New Music from {bandcamp_url}</title>
                <link>{bandcamp_url}</link>
                <description>New releases by your favorite Bandcamp artists.</description>
                {items_content}
            </channel>
        </rss>'''
        requests.post(rss_feed_url, data=rss_content.encode('utf-8'), headers={'Content-type': 'application/rss+xml'})
    else:
        for href in href_list:
            if href not in [entry.link for entry in d.entries]:
                d.entries.append({'title': href.split('/')[-1].replace('-', ' ').title(), 'link': href})
                items_content = process_links([href])
                rss_content = f'''<?xml version="1.0" encoding="UTF-8"?>
        <rss version="2.0">
            <channel>
                <title>New Music from {bandcamp_url}</title>
                <link>{bandcamp_url}</link>
                <description>New releases by your favorite Bandcamp artists.</description>
                {items_content}
            </channel>
        </rss>'''
                requests.post(rss_feed_url, data=rss_content.encode('utf-8'), headers={'Content-type': 'application/rss+xml'})
    time.sleep(60*30) # Wait for 30 minutes and repeat
{}
region:us
TAGS
#region-us 

import feedparser
import requests
from bs4 import BeautifulSoup
import time

# Enter the bandcamp URL of the artist you want to track
bandcamp_url = 'URL

# Enter the URL for the RSS feed service you are going to use to receive updates
rss_feed_url = 'URL

# Define the headers for the requests
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'}

# Initialize the parser
d = feedparser.FeedParserDict()

# Get the links for the music from the Bandcamp page
def get_links_from_page(url):
    response = URL(url, headers=headers)
    soup = BeautifulSoup(URL, 'URL')
    href_list = []
    for a in soup.find_all('a', href=True):
        if '/track/' in a['href']:
            href_list.append('https://'+a['href'][2:])
    return href_list

# Process the links and format them into RSS items
def process_links(href_list):
    items_content = ''
    for href in href_list:
        name = URL('/')[-1].replace('-', ' ').title()
        items_content += f'<item><title>New Music from {name}</title><link>{href}</link><description>New music released by {name}. Check it out!</description></item>'
    return items_content

# Loop through and update for new content
while True:
    href_list = get_links_from_page(bandcamp_url)
    if not d.entries:
        for href in href_list:
            d.URL({'title': URL('/')[-1].replace('-', ' ').title(), 'link': href})
        items_content = process_links(href_list)
        rss_content = f'''<?xml version="1.0" encoding="UTF-8"?>
        <rss version="2.0">
            <channel>
                <title>New Music from {bandcamp_url}</title>
                <link>{bandcamp_url}</link>
                <description>New releases by your favorite Bandcamp artists.</description>
                {items_content}
            </channel>
        </rss>'''
        URL(rss_feed_url, data=rss_content.encode('utf-8'), headers={'Content-type': 'application/rss+xml'})
    else:
        for href in href_list:
            if href not in [URL for entry in d.entries]:
                d.URL({'title': URL('/')[-1].replace('-', ' ').title(), 'link': href})
                items_content = process_links([href])
                rss_content = f'''<?xml version="1.0" encoding="UTF-8"?>
        <rss version="2.0">
            <channel>
                <title>New Music from {bandcamp_url}</title>
                <link>{bandcamp_url}</link>
                <description>New releases by your favorite Bandcamp artists.</description>
                {items_content}
            </channel>
        </rss>'''
                URL(rss_feed_url, data=rss_content.encode('utf-8'), headers={'Content-type': 'application/rss+xml'})
    URL(60*30) # Wait for 30 minutes and repeat
# Enter the bandcamp URL of the artist you want to track
bandcamp_url = 'URL # Enter the URL for the RSS feed service you are going to use to receive updates
rss_feed_url = 'URL # Define the headers for the requests
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'} # Initialize the parser
d = feedparser.FeedParserDict() # Get the links for the music from the Bandcamp page
def get_links_from_page(url):
    response = URL(url, headers=headers)
    soup = BeautifulSoup(URL, 'URL')
    href_list = []
    for a in soup.find_all('a', href=True):
        if '/track/' in a['href']:
            href_list.append('https://'+a['href'][2:])
    return href_list # Process the links and format them into RSS items
def process_links(href_list):
    items_content = ''
    for href in href_list:
        name = URL('/')[-1].replace('-', ' ').title()
        items_content += f'<item><title>New Music from {name}</title><link>{href}</link><description>New music released by {name}. Check it out!</description></item>'
    return items_content # Loop through and update for new content
while True:
    href_list = get_links_from_page(bandcamp_url)
    if not d.entries:
        for href in href_list:
            d.URL({'title': URL('/')[-1].replace('-', ' ').title(), 'link': href})
        items_content = process_links(href_list)
        rss_content = f'''<?xml version="1.0" encoding="UTF-8"?>
        <rss version="2.0">
            <channel>
                <title>New Music from {bandcamp_url}</title>
                <link>{bandcamp_url}</link>
                <description>New releases by your favorite Bandcamp artists.</description>
                {items_content}
            </channel>
        </rss>'''
        URL(rss_feed_url, data=rss_content.encode('utf-8'), headers={'Content-type': 'application/rss+xml'})
    else:
        for href in href_list:
            if href not in [URL for entry in d.entries]:
                d.URL({'title': URL('/')[-1].replace('-', ' ').title(), 'link': href})
                items_content = process_links([href])
                rss_content = f'''<?xml version="1.0" encoding="UTF-8"?>
        <rss version="2.0">
            <channel>
                <title>New Music from {bandcamp_url}</title>
                <link>{bandcamp_url}</link>
                <description>New releases by your favorite Bandcamp artists.</description>
                {items_content}
            </channel>
        </rss>'''
                URL(rss_feed_url, data=rss_content.encode('utf-8'), headers={'Content-type': 'application/rss+xml'})
    URL(60*30) # Wait for 30 minutes and repeat
TAGS
#region-us 
 # Enter the bandcamp URL of the artist you want to track
bandcamp_url = 'URL # Enter the URL for the RSS feed service you are going to use to receive updates
rss_feed_url = 'URL # Define the headers for the requests
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'} # Initialize the parser
d = feedparser.FeedParserDict() # Get the links for the music from the Bandcamp page
def get_links_from_page(url):
    response = URL(url, headers=headers)
    soup = BeautifulSoup(URL, 'URL')
    href_list = []
    for a in soup.find_all('a', href=True):
        if '/track/' in a['href']:
            href_list.append('https://'+a['href'][2:])
    return href_list # Process the links and format them into RSS items
def process_links(href_list):
    items_content = ''
    for href in href_list:
        name = URL('/')[-1].replace('-', ' ').title()
        items_content += f'<item><title>New Music from {name}</title><link>{href}</link><description>New music released by {name}. Check it out!</description></item>'
    return items_content # Loop through and update for new content
while True:
    href_list = get_links_from_page(bandcamp_url)
    if not d.entries:
        for href in href_list:
            d.URL({'title': URL('/')[-1].replace('-', ' ').title(), 'link': href})
        items_content = process_links(href_list)
        rss_content = f'''<?xml version="1.0" encoding="UTF-8"?>
        <rss version="2.0">
            <channel>
                <title>New Music from {bandcamp_url}</title>
                <link>{bandcamp_url}</link>
                <description>New releases by your favorite Bandcamp artists.</description>
                {items_content}
            </channel>
        </rss>'''
        URL(rss_feed_url, data=rss_content.encode('utf-8'), headers={'Content-type': 'application/rss+xml'})
    else:
        for href in href_list:
            if href not in [URL for entry in d.entries]:
                d.URL({'title': URL('/')[-1].replace('-', ' ').title(), 'link': href})
                items_content = process_links([href])
                rss_content = f'''<?xml version="1.0" encoding="UTF-8"?>
        <rss version="2.0">
            <channel>
                <title>New Music from {bandcamp_url}</title>
                <link>{bandcamp_url}</link>
                <description>New releases by your favorite Bandcamp artists.</description>
                {items_content}
            </channel>
        </rss>'''
                URL(rss_feed_url, data=rss_content.encode('utf-8'), headers={'Content-type': 'application/rss+xml'})
    URL(60*30) # Wait for 30 minutes and repeat