Skip to content

Commit

Permalink
Add experimental features
Browse files Browse the repository at this point in the history
* Add video link to episode description
* Use shorter youtube links in rss feed
* Add maxVideoHeight parameter
* Update README.md
* Bump version
  • Loading branch information
trevorsharp authored Apr 26, 2022
1 parent 4725c91 commit 4f589d8
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 9 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,12 @@ _Example:_ `"Ep ([0-9]+)"` would be used to extract the episode number (`123`) f
The string replacement (second element of the sub-array) can use the RegExp.$1-$9 properties (see [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/n) for more info on how these are used). Common separators (`-` and `|`) are cleaned up automatically.

_Example:_ `[["Podcast Name", ""], ["Ep ([0-9]+)", "#$1"]]` will transform `Podcast Episode Title | Podcast Name | Ep 123` into `Podcast Episode Title | #123`.

## Experimental Features

These features are experimental, and they may reduce compatibility, increase resource usage, and cause problems. Proceed with caution.

#### Additional Parameters

- **maxQualityVideo** - If true, video quality downloads will be allowed to exceed 1080p. Must be used in conjunction with `highQualityVideo` parameter set to true - _Default: false_
- **maxVideoHeight** - Number to represent the maximum height of downloaded videos in pixels. Must be used in conjunction with `maxQualityVideo` parameter set to true. Suggested values are 2160 and 1440 - _Default: 2160_
2 changes: 1 addition & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"maxEpisodes": 0,
"highQualityVideo": false,
"maxQualityVideo": false,
"maxQualityUserAgent": "^$"
"maxVideoHeight": 2160
}
9 changes: 5 additions & 4 deletions downloadVideos.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
downloadList=$1
directory=$(dirname $1)
maximumQuality=$2
cookieFile=$3
maxHeight=$3
cookieFile=$4

youtubeBaseUrl="https://youtube.com/watch?v="

Expand All @@ -12,7 +13,7 @@ while read videoId; do
if [ "$maximumQuality" != "true" ]; then
highQualityVideoUrl=""
else
highQualityVideoUrl=$(yt-dlp -g -f "bv[height>1080][vcodec^=vp9]" ${cookieFile:+--cookies $cookieFile} "$youtubeBaseUrl$videoId" 2>/dev/null)
highQualityVideoUrl=$(yt-dlp -g -f "bv[height>1080][height<=${maxHeight}][vcodec^=vp9]" ${cookieFile:+--cookies $cookieFile} "$youtubeBaseUrl$videoId" 2>/dev/null)
fi

if [ "$highQualityVideoUrl" == "" ]; then
Expand All @@ -25,7 +26,7 @@ while read videoId; do
wait
else
yt-dlp \
-f "bv[vcodec^=vp9]+ba[ext=m4a]" \
-f "bv[vcodec^=vp9][height<=${maxHeight}]+ba[ext=m4a]" \
--merge-output-format=mkv \
-o "$directory/%(id)s.%(ext)s" \
${cookieFile:+--cookies $cookieFile} \
Expand All @@ -38,7 +39,7 @@ while read videoId; do
-i "$directory/$videoId.mkv" \
-c:v libx264 \
-c:a copy \
-preset ultrafast \
-preset veryfast \
-r 30 \
-start_number 0 \
-hls_time 10 \
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "youtube-podcast-feeds",
"version": "1.2.5",
"version": "1.2.6",
"main": "index.js",
"author": "Trevor Sharp <[email protected]>",
"license": "MIT",
Expand Down
11 changes: 8 additions & 3 deletions src/services/rssService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,20 @@ class RssService {
? { itunesEpisode: Number(RegExp.$1) }
: {};

const youtubeUrl = `https://youtu.be/${video.id}`;
const videoUrl = `${config.hostname}/video/${video.id}`;

const description = `${video.description.trim()}\n\n${youtubeUrl}`;

const itunesDuration = video.duration;

rssFeed.addItem({
title: title,
itunesTitle: title,
description: video.description,
description,
date: new Date(video.date),
enclosure: { url: `${config.hostname}/video/${video.id}`, type: 'video/mp4' },
url: `https://www.youtube.com/watch?v=${video.id}`,
enclosure: { url: videoUrl, type: 'video/mp4' },
url: youtubeUrl,
itunesDuration,
...episodeNumber,
});
Expand Down
1 change: 1 addition & 0 deletions src/services/videoService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class VideoService {
'./downloadVideos.sh',
config.downloadsFilePath,
config.maxQualityVideo.toString(),
config.maxVideoHeight.toString(),
fs.existsSync(config.cookiesFilePath) ? config.cookiesFilePath : '',
]);

Expand Down
2 changes: 2 additions & 0 deletions src/utilities/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Config {
readonly maxEpisodes: number;
readonly highQualityVideo: boolean;
readonly maxQualityVideo: boolean;
readonly maxVideoHeight: number;
readonly feedConfigs: FeedConfig[];

private constructor() {
Expand All @@ -39,6 +40,7 @@ class Config {
this.maxEpisodes = Math.floor(config.get('maxEpisodes'));
this.highQualityVideo = config.get('highQualityVideo');
this.maxQualityVideo = config.get('maxQualityVideo');
this.maxVideoHeight = config.get('maxVideoHeight');

this.hostname = config.has('hostname')
? config.get('hostname')
Expand Down

0 comments on commit 4f589d8

Please sign in to comment.