Skip to content

Podfetch

Prerequisites

This script depends on the watchdog python package. To install it you will first need PIP installed on your server. PIP is the package manager for Python.

  1. See if PIP is already installed. Open a terminal and type: pip -V

  2. If not, install it. python get-pip.py

  3. Once installed, install watchdog pip install watchdog

Note: You may need to use pip3

Folder Structure

If you have not done so already, create a new folder called scripts in your home folder. This is where all your scripts will go.

Inside your scripts folder create a new folder called podfetch

When done your folders structure should look like this: /home/[username]/scripts/podfetch

Script

Get the source code (1) then save the code as podcast_folder_monitor.py in the podfetch folder.

  1. Note: You can find the source code to all scripts by clicking the euronvault/eScripts link at the top of this wiki.

Make sure to replace /some/folder/to/monitor with the actual path of the folder you want to monitor making sure to leave the quotation marks.

Next we need to change the permissions of this file so that the server can read it.

  1. Right click on podcast_folder_monitor.py then Properties.
  2. Click on Permissions tab at top.
  3. Make sure Owner & Group reflect your username with Read and Write access to all.
  4. Check the Execute box to allow executing the file as a program.
  5. Close out the window.

Run

Now we need to test and run the script.

Make sure your terminal is open to the location of the podcast_folder_monitor.py file. Should be ~/scripts/podcast

Normally to run a Python script will would use python3 podcast_folder_monitor.py

This will still work but because we have shebang set in the script we can just use ./podcast_folder_monitor.py

You should now see the blinking curser in the terminal indicating that the script is running and monitoring the folder for a new file.

testing

Testing

To test the script,

Copy and paste one of your new podcast folders (1) into the monitored folder we set in the code. The script should notice the change and rename the .mp3 to the name of the parent folder.

  1. Note: One that includes podcast.mp3

testing

Automation

This script can be automated. See system services.