Forum

Thread tagged as: Question, Addons, Podcasts

Podcasts Episode URL

Hi, I was wondering if there was a way that Perch would rename the mp3 files as it's being uploaded. The default tracked URL is:

/podcasts/play/{showSlug}/{episodeNumber}.mp3

The only way to get the page to link to the file correctly is if I change the file name to the episode number .mp3 (for example 1.mp3, 2.mp3, etc.)

Am I not using this addon correctly? I would like to title each podcast with the date (2016-02-04) and upload my file as 2016-02-04.mp3 (if Perch cannot rename this file automatically, that's fine. I will manually rename the file before each upload). But then I'd like to have Perch create the appropriate link (/podcasts/play/slug/2016-02-04.mp3)

I tried editing the tracked URL to:

/podcasts/play/{showSlug}/{episodeTitle}.mp3

But that just broke the link and the episode title does not appear where it's supposed to. I end up getting:

/podcasts/play/slug/.mp3

Marvin Wong

Marvin Wong 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

There are two factors:

  1. The file name of the MP3 - this is internal
  2. The tracked URL that you publish to the world

These shouldn't be the same - they need to be different in order to track downloads.

Is there additional documentation somewhere that explains how to do this? I checked through all those in the Perch documentation and it's not very helpful.

I used all the default example pages and everything works except for the play button on the actual podcast page. The html output URL is showing as:

/podcasts/play/slug/1.mp3

The play works just fine from the Perch admin side and is showing the actual URL as:

/perch/resources/uploaded-file-name.mp3

I guess my question is how do you link the tracked URL to play from the MP3 file in my resources folder (since the URLs are different)?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you using the example files that come with the app? The page function that tracks the play and redirects to the real file is perch_podcasts_track_play()

https://docs.grabaperch.com/addons/podcasts/page-functions/perch-podcasts-track-play/

Yes, I am using the example files that come with the app. Where does the play.php file come into use (since that is where the perch_podcasts_track_play() function is located)?

The podcasts are showing up on episode.php as they should be, but the play button is grayed out. This is the html output I'm getting on this page:

<audio controls>
    <source src="https://www.pbbcgroton.org/podcasts/play/show1/1.mp3" type="audio/mpeg" /> 
</audio>

I'm using all the default templates by the way.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is the path correct?

The path matches the tracked URL, although that path does not actually exist because the actual file is located in /perch/resources/symphony_8.mp3

Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you have a rewrite rule in place to serve the tracked URL?

I do and although I'm not very familiar with rewrite rules (although I just read up on it), everything seems to be redirecting as it should.

I first tried entering in the address bar "https://www.pbbcgroton.org/podcasts/play.php?show=show1&ep=1" and that correctly directs me to the location of the mp3 file "https://www.pbbcgroton.org/perch/resources/symphony_8.mp3"

And my .htaccess has the correct entries:

Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteRule ^play/([0-9a-z-]*)/([0-9]+).*?$ /podcasts/play.php?show=$1&ep=$2

Yet when I try "https://www.pbbcgroton.org/podcasts/play/show1/1.mp3" it cannot find the appropriate link.

As a test, I tried the following example and it redirected correctly to the mp3 file when I went to the contact page:

RewriteRule ^contact.php$ /podcasts/play.php?show=show1&ep=1

It makes me think the problem is within the first half of the rewrite rule.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Your rule begins with play but the example you gave is /podcasts/play.

RewriteRule ^podcasts/play/([0-9a-z-]*)/([0-9]+).*?$ /podcasts/play.php?show=$1&ep=$2

Thank you so much! :)

That did it. Just a side note - that rule example was copied from the example .htaccess file from the download. And of course I didn't know enough to change it. But thanks again!

Drew McLellan

Drew McLellan 2638 points
Perch Support

If you have trouble with rewrite rules, Perch Runway eliminates the need to create them.