You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.htm
+14-8Lines changed: 14 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@
35
35
</head>
36
36
<body>
37
37
<h1>SoundsDownloadScript.ps1 + genRSS.ps1</h1>
38
-
<p><i>*Updated: 5-Nov-2024 02:24 GMT</i></p>
38
+
<p><i>*Updated: 18-Nov-2024 22:21 GMT</i></p>
39
39
<p>These instructions are very crude and messy. Sorry for the windbag word vomit. I hope they help, though. If someone wants to convert this file into a markdown README.md for github, be my guest. The scripts are a little tedious to set up the first time, but once you get them working they're pretty reliable and easy to maintain.</p>
40
40
<p>I recommend you check the <ahref="https://github.com/endkb/SoundsDownloadScript">repo on github</a> for the <ahref="https://raw.githack.com/endkb/SoundsDownloadScript/main/README.htm">latest version of this README</a> before continuing.</p>
41
41
<p>If you find a bug in the scripts or something is incorrect or incomplete in the documentation, feel free to <ahref="https://github.com/endkb/SoundsDownloadScript/issues">open an issue on github</a>.</p>
<li><code>$VPNAdapter</code>: [<i>String</i>] Name of the adapter used by OpenVPN. Run <code>Get-NetAdapter</code> in Powershell to get your list of adapter names. You'll want the Name, not the InterfaceDescription. Mine is 'OpenVPN TAP-Windows6'. The script will use this to determine when the VPN is connected and disconnected to continue on. Only needed if using VPN.</li>
131
131
<li><code>$VPNTimeout</code>: [<i>Number of seconds</i>] Number of seconds to wait before giving up on VPN if it doesn't connect. Remember that while it's waiting, the script will pause and could tie up other instances that are also waiting to run, so set it for a reasonable number of seconds. Only needed if using VPN.</li>
132
132
<br>
133
-
<li><code>$ScriptInstanceControl</code>: [<i>$true,$false</i>] This controls the instances of the script that can download at a time. If ANY of your instances are using VPN, you should set this to <code>$true</code>. If it's enabled, it works like this: If an instance is not configured to use VPN, other instances that are also not using the VPN can download at the same time. If an instance that needs VPN wants to download, it must wait until all other instances are done instances are done. If another script is downloading, the current one will wait. If multiple scripts are connecting and disconnecting the VPN it will screw up downloads. Only needed if using ScriptInstanceControl.</li>
133
+
<li><code>$ScriptInstanceControl</code>: [<i>$true,$false</i>] This controls the instances of the script that can download at a time. If ANY of your instances are using VPN, you should set this to <code>$true</code>. If it's enabled, it works like this: If an instance is not configured to use VPN, other instances that are also not using the VPN can download at the same time. If an instance that needs VPN wants to download, it must wait until all other instances are done instances are done. If another script is downloading, the current one will wait. If multiple scripts are connecting and disconnecting the VPN, it will screw up downloads. You really only need this if you're using VPN.</li>
134
134
<li><code>$LockFileDirectory</code>: [<i>Directory path</i>] Directory to save lock files for <code>$ScriptInstanceControl</code>. Specify a non-environment dir (like not the user's temp dir) if the script is running under different user accounts. The paths will need to be accessible by all accounts and have read and write permissions for it to work properly. Only needed if using <code>$ScriptInstanceControl</code>.</li>
135
135
<li><code>$LockFileMaxDuration</code>: [<i>Number of seconds</i>] This is the maximum age in seconds before lock files are deleted. This keeps script from getting hung up by orphaned lock files. It's rare, but it can happen if the script is interrupted during a download. To disable (not recommended), set to <code>0</code>. Only needed if using <code>$ScriptInstanceControl</code>.<br><br></li>
<li><code>$Logging = $true</code> = Save logs for all downloads</li>
143
143
<li><code>$Logging = $false</code> = Don't save logs for any downloads</li>
144
144
<li><code>$Logging > $null</code> = Use whatever is set in the command line parameter per instance (<code>$Logging = $Logging</code> will also have the same effect)</li>
145
-
</ul>
145
+
</ul>
146
146
</li>
147
147
<li><code>$Printjson</code>: [<i>$true,$false</i>] Prints the raw json data from <code>$jsonResult</code> to the console. It will also be saved to the log if <code>$Logging</code> is enabled. The text can be copied and pasted into an <ahref="https://codebeautify.org/jsonviewer">online json viewer</a> for better readability. Use this for troubleshooting things like parsing issues, special character issues, or finding a reference point to retrieve a json value (see <ahref="#TitleFormat">TitleFormat</a> under the Documentation section). The Console+Vars log files will be significantly larger if this setting is left on.</li>
148
148
<li><code>$LogDirectory</code>: [<i>Directory path</i>] This is the directory to move logs to when the <code>-Logging</code> switch is present or when <code>$Logging</code> is set to <code>$true</code>. You'll want to check this directory once in a while because the logs can get unwieldy.</li>
<li><code>Directory</code>: [<i>Directory path</i>] Local directory to save the RSS file.</li>
225
225
<li><code>RSSFileName</code>: [<i>File name</i>] Name of the RSS file to save locally. This is the file that will get uploaded.<br><br></li>
226
226
227
-
<li><code>CheckMediaDirectoryHash</code>: [<i>yes,no</i>] Uses a hash of the directory structure instead of LastWriteTime to determine whether the media files have changed and to republish the RSS. This can be better because checking LastWriteTime won't detect changes if only a file was deleted. If <code>CheckMediaDirectoryHash</code> is set to <code>yes</code> then each time the script is called, it will compute the MD5 hash value of the MediaDirectory using MD5CryptoServiceProvider and save it into the RSS. When it is called again, it will pull the hash from the RSS and compare the values. The hash will be saved in <MediaDirectoryHash> as a child of the <rss> element outside of the <channel> element of the RSS. If <code>CheckMediaDirectoryHash</code> is <code>no</code> or is not set, genRSS compares the file with the latest LastWriteTimeUtc to the time the RSS was last generated (<lastBuildDate>) to know whether to update republish the RSS.</li>
227
+
<li><code>CheckMediaDirectoryHash</code>: [<i>'contents','filenames','no'</i>] Uses a hash to determine whether the media files have changed and to republish the RSS. If <code>CheckMediaDirectoryHash</code> is set to <code>contents</code> or <code>filenames</code> then each time the script is called, it will compute the MD5 hash value of the MediaDirectory and save it into the RSS. When it is called again, it will pull the hash from the RSS and compare the values. The hash will be saved in <MediaDirectoryHash> as a child of the <rss> element outside of the <channel> element of the RSS. If <code>CheckMediaDirectoryHash</code> is <code>no</code> or is not set, genRSS compares the file with the latest LastWriteTimeUtc to the time the RSS was last generated (<lastBuildDate>) to know whether to update republish the RSS. Possible values are:</li>
228
+
<ul>
229
+
<li><code>contents</code> = Scans each file in the <code>MediaDirectory</code> and calculates a hash of the contents using ReadAllBytes and ComputeHash. This will also detect changes to metadata. Use this if you're using the <code>-RecheckMetadata</code> option in SoundsDownloadScript. This will be pretty slow if there are a lot of files or of the files are large.</li>
230
+
<li><code>filenames</code> = Computes the MD5 hash value of the <code>MediaDirectory</code> filenames only using MD5CryptoServiceProvider. This will detect file additions or deletions, but not changes to metadata.</li>
231
+
<li><code>no</code> = Don't take a hash. Use LastWriteTime of the latest file in <code>MediaDirectory</code> to determine whether the RSS needs to be updated. This is the fastest option, but it won't detect changes if only a file was deleted and not added. This is the default value if <code>CheckMediaDirectoryHash</code> is not set.</li>
232
+
</ul>
228
233
<li><code>CheckProfileHash</code>: [<i>yes,no</i>] Updates the RSS file if there are changes to the podcast profile. Normally, genRSS will only update the RSS file when there is a new episode. If <code>CheckProfileHash</code> is set to <code>yes</code> then the next time the script is called, it will put the MD5 hash value of the profile into the RSS using Get-FileHash. When it is called again, it will pull the hash from the RSS and compare the values. If they are different, then it knows that the profile was updated and the RSS needs to be regenerated and republished. The hash will be put into <ProfileHash> as a child of the <rss> element outside of the <channel> element in the RSS.<br><br></li>
229
234
230
235
<li><code>rcloneConfig</code>: [<i>File path</i>] Path to the rclone ini config file.</li>
<li><code>MediaRootURL</code>: [<i>URL</i>] This should be the publicly accessible URL path that podcast apps can download the episodes. It should normally be an HTTP directory and then the script will add the file name to the end. I <i>think</i> it could also be a file hosted locally on a windows or smb share by using <code>file://</code> instead, but I haven't tested it.</li>
253
258
<li><code>RerunLabel</code>: [<i>String</i>] A label to prepend to episode titles when the episode is a rerun according to the criteria in <code>RerunFiles</code> or <code>RerunTitles</code>. Include a delimiting character like a colon or dash if you'd like. A space is NOT automatically included. To include a space between the label and the title, surround the value in quotes or double quotes (<code>"Repeat: "</code>).</li>
254
-
<li><code>AutoDetectReruns</code>: [<i>yes,no,number of days greater than 0</i>] Specify the number of days after the original air date that an episode should be considered a rerun. In other words, try to determine whether the episode is a rerun by comparing the original date (Original Date or TDOR) to the most recent release date (Release Date or TOAL) of the episode. If it's over the number of days specified, the script marks it as a rerun. If the value is <code>yes</code> then a default of 90 days is used. If the value is <code>no</code> or is not present, the feature is disabled.</li>
259
+
<li><code>AutoDetectReruns</code>: [<i>yes,no,Number of days greater than 0</i>] Specify the number of days after the original air date that an episode should be considered a rerun. In other words, try to determine whether the episode is a rerun by comparing the original date (Original Date or TDOR) to the most recent release date (Release Date or TOAL) of the episode. If it's over the number of days specified, the script marks it as a rerun. If the value is <code>yes</code> then a default of 90 days is used. If the value is <code>no</code> or is not present, the feature is disabled.</li>
255
260
<li><code>RerunFiles</code>: [<i>String</i>] Searches the episode file names for this text to decide whether it's a rerun. Separate entries by a comma with no space. I recommend using the BBC program ID.</li>
256
261
<li><code>RerunTitles</code>: [<i>String</i>] Searches the episode titles for this text to decide whether it's a rerun. Separate entries by a comma and without a space. I suggest putting the Series numbers in here (Ex: <code>Series 21,Series 22</code>).</li>
257
262
<li><code>SkipFiles</code>: [<i>String</i>] Searches the episode file names for this text to decide whether to skip the file. Separate entries by a comma. I recommend using the BBC program ID. These episodes will not be included in the RSS.</li>
<li><code>{4}</code> = Current date and time (must only include <ahref="https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file">legal file name chars</a>; <code>{4:yyyyMMdd_HHmmss}</code> is a good format)</li>
273
278
</ul>
274
279
This can also be given as a command line parameter (<code>-LogFileNameFormat</code>) or globally as a configurable option in the script (<code>$LogFileNameFormat</code>), instead.
275
-
<br><br></ul>
280
+
</ul>
276
281
<li>Profit! (actually, don't profit because I want this project to stay off the BBC's radar)</li>
<li><code>{3}</code> = The release date and/or time in UTC. A DateTime format should follow. An example would be (3:[DateTimeFormat]} ex: <code>{3:HH:mm}</code></li>
296
301
<li><code>{4}</code> = The release date and/or time in UK time. See above.</li>
297
302
</ul>
298
-
An often useful format for serialized shows is <code>'{1} - {2}'</code> which will set the series and episode numbers: Series 15 - Episode 4.
303
+
An often useful format for serialized shows is <code>'{1} - {2}'</code> which will usually set the series and episode numbers: Series 15 - Episode 4.
299
304
</li>
300
305
<li><code>-UseOrigRelease</code>: [<i>Switch</i>] Sets the release date of the episode to the original date the episode aired. Without this parameter, it uses the most recent availability date. When this parameter is set, the RELEASEDATE/TDRL and ORIGINALDATE/TDOR tags will have the same value. This will affect the file name and also the <pubDate> tag in genRSS.</li>
301
306
<li><code>-Bitrate</code>: [<i>Number of kilobits</i>] Specify the bitrate stream that yt-dlp should download. Set to <code>0</code> to have yt-dlp download the highest bitrate available. It must be the number of kilobits per second (kbps), and only the number. The higher the bitrate, the higher the audio the quality and the bigger the file size. Available bitrates are generally <code>48</code>, <code>96</code>, <code>128</code>, and <code>320</code>. If the specified bitrate is not available, yt-dlp will fail to download the program and will throw an error that says <code>Requested format is not available</code>. You can view the bitrates that are available for a particular stream by running:
<li><code>-mp3</code>: [<i>Switch</i>] Transcode the audio file to mp3 using ffmpeg after downloading. The default is file type is m4a. Uses libmp3lame codec and mirrors the bitrate of the m4a file. Note: I don't do as much testing on the mp3 option (e.g., m4a and mp3 use different tags). If you find a bug with it, <ahref="https://github.com/endkb/SoundsDownloadScript/issues">open an issue</a> in the repo.</li>
306
311
<li><code>-Archive</code>: [<i>Number</i>] The number of episodes to keep. Set to <code>0</code> to disable and keep all episodes. After the script downloads the latest one, it will delete excess ones. It searches for episodes using the ShortTitle. If multiple shows are saved in the same folder for some reason, the other shows will not be deleted.</li>
307
312
<li><code>-Days</code>: [<i>Switch</i>] Bases the <code>-Archive</code> parameter on the number of days to keep instead of the number of episodes. This option reads the date from each filename (which is set from the episode's GMT release date in the metadata). If Archive is <code>0</code> or is not set, this parameter has no effect.</li>
308
-
<li><code>-VPNConfig</code>: [<i>String array of file paths</i>] If using a VPN, this is the path to the OpenVPN .ovpn config file. It can also be an array of file locations separated by a comma. Since the BBC tries to block VPNs in a cat and mouse game, the script will run through each config in order until it finds one that can download the episode. I use PIA for VPN. Also be sure create and set an auth-user-pass file if using. See OpenVPN support for that.</li>
313
+
<li><code>-RecheckMetadata</code>: [<i>Switch</i>] Refreshes the metadata of all media files to pull any changes from the BBC. It searches recursively for files matching the <code>-ShortTitle</code> and fetches the latest metadata from the episode page on the BBC's website. If there are discrepancies, it updates the media file’s title and comment. I would only use it with the <code>-Archive</code> option because it can be slow if you have a lot of files since it has to pull the web page of each file individually. Use case: Sometimes the BBC doesn't set the real title or description of a show until after it has already been published to Sounds. If you're also using genRSS to build a podcast feed, you'll want to specify <code>CheckMediaDirectoryHash=contents</code> in the podcast profile so that genRSS detects the changes and updates the feed with the new metadata.</li>
314
+
<li><code>-VPNConfig</code>: [<i>String array of file paths</i>] If using a VPN, this is the path to the OpenVPN .ovpn config file. It can also be an array of file locations separated by a comma. Since the BBC tries to block VPNs in a cat and mouse game, the script will run through each config in order until it finds one that can download the episode. If you're using VPN and running the script from the task scheduler, I would set the task to run more often so it gets more chances to work. I use PIA for VPN. Also be sure create and set an auth-user-pass file if using. See OpenVPN support for that.</li>
309
315
<li><code>-rcloneConfig</code>: [<i>File path</i>] If using rclone to upload the episode somewhere, this is the path to the rclone config file. You'll need to use:
0 commit comments