If what I'm doing is not best practice, I'm open to other methods.
Eu sugiro que você não use bash
ou sed
etc.! E vá com uma maneira python, que é definitivamente uma maneira muito melhor de analisar o xml que você precisa analisar. Eu acabei de escrever e testar isso com o python3.6 e ele faz exatamente o que você pediu.
#!/usr/bin/python3
# Let's import the modules we need
import wget
import os
import requests
from bs4 import BeautifulSoup as bs
# Assign the url to a variable (not essential as we
# only use it once, but it's pythonic)
url = 'https://librivox.org/api/feed/audiobooks/?offset=0&limit=3&fields=%7Blanguage,authors,title,url_zip_file%7B'
# Use requests to fetch the raw xml
r = requests.get(url)
# Use BeautifulSoup and lxml to parse the raw xml so
# we can do stuff with it
s = bs(r.text, 'lxml')
# We need to find the data we need. This will find it and create some
# python lists for us to loop through later
# Find all xml tags named 'url_zip_file' and assign them to variable
links = s.find_all('url_zip_file')
# Find all xml tags named 'last_name' and assign them to variable
last_names = s.find_all('last_name')
# Find all xml tags named 'last_name' and assign them to variable
first_names = s.find_all('first_name')
# Find all xml tags named 'language' and assign them to variable
language = s.find_all('language')
# Assign the language to a variable
english = language[0].text
# Make our new language directory
os.mkdir(english)
# cd into our new language directory
os.chdir(str(english))
# Loop through the last names (ln), first names(fn) and links
# so we can make the directories, download the file, rename the
# file then we go back a directory and loop again
for ln, fn, link in zip(last_names, first_names, links):
os.mkdir('Author{}{}'.format(str(ln.text), str(fn.text)))
os.chdir('Author{}{}'.format(ln.text, fn.text))
filename = wget.download(link.text)
os.rename(filename, 'File.zip')
os.chdir('../')
Você pode salvá-lo em um arquivo ou simplesmente colar / digitar em um interpretador de clones python3, depende de você.
Você precisará instalar o python3-wget e beautifulsoup4 usando pip ou easy_install etc.