#!/bin/bash -e

temp=$(mktemp -d)

test -e "$repo" || mkdir -p "$repo"

cd $temp
youtube-dl -c --output '%(upload_date)s - %(id)s : %(title)s.%(ext)s' --write-description --extract-audio --download-archive $repo/dl-memo.log youtube.com/user/Pirulla25

for f in *.description; do
  orig="$( ls "$name"* | grep -v 'description$' | head -n1 )"
  echo -e "\n>> Processando $name..."
  avconv -i "$orig" -ab 128k audio.mp2
  sed -r 's!https?://(www\.)?|/(\s|$)|\?v=[^\s]+! !g' "$f" > description.txt
  espeak -f description.txt -v pt -w description.wav
  avconv -i description.wav -ab 128k description.mp2
  avconv -i "concat:description.mp2|audio.mp2" -ab 128k "$repo/$name.mp3"
  mv "$f" "$repo/$f"
  ls "$name"* description.* audio.mp2
  rm "$name"* description.* audio.mp2

cd $repo

echo -e '\n>> Atualizando RSS...'
echo '<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<description>Canal Pirula em √°udio</description>
echo "<lastBuildDate>$(date +%FT%T)</lastBuildDate>"
for f in *.description; do
  echo ">> Atualizando $name..." >&2
  nEsq=$( echo "$name" | sed -r 's/%/%25/g; s/\?/%3F/g; s/#/%23/g; s/&/%26/g' )
  pubDate="$( echo "$name" | sed -r 's/^(....)(..)(..) -.*/\1-\2-\3/' )T00:00:00"
  id="$(      echo "$name" | sed -r 's/^[0-9]+ - ([^:]+) :.*/\1/' )"
  title="$(   echo "$name" | sed -r 's/^[^:]+: //' )"
  echo "  <item>
    <description><![CDATA[$(cat "$f")]]></description>
    <enclosure url=\"$base_url/$nEsq.mp3\"
               length=\"$(du -b "$name.mp3" | cut -f1)\" type=\"audio/mpeg3\" />
echo '</channel>
) > $temp/pirula.rss

mv $temp/pirula.rss $repo/pirula.rss
rm -r $temp

echo '>> Done!'
Topic revision: r1 - 26 Apr 2016, UnknownUser
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Wiki-Colivre? Send feedback