feat(media): save audio, images, transcripts and chapters to media for episode and persons

This commit is contained in:
Yassine Doghri 2021-12-20 17:12:12 +00:00
commit 58e2a00a87
22 changed files with 144 additions and 129 deletions

View file

@ -131,6 +131,10 @@ class PodcastImportController extends BaseController
if (property_exists($nsPodcast, 'guid') && $nsPodcast->guid !== null) {
$guid = (string) $nsPodcast->guid;
}
$db = db_connect();
$db->transStart();
$podcast = new Podcast([
'guid' => $guid,
'handle' => $this->request->getPost('handle'),
@ -139,7 +143,7 @@ class PodcastImportController extends BaseController
'title' => (string) $feed->channel[0]->title,
'description_markdown' => $converter->convert($channelDescriptionHtml),
'description_html' => $channelDescriptionHtml,
'cover' => new Image($coverFile),
'cover' => $coverFile,
'banner' => null,
'language_code' => $this->request->getPost('language'),
'category_id' => $this->request->getPost('category'),
@ -185,10 +189,6 @@ class PodcastImportController extends BaseController
}
$podcastModel = new PodcastModel();
$db = db_connect();
$db->transStart();
if (! ($newPodcastId = $podcastModel->insert($podcast, true))) {
$db->transRollback();
return redirect()
@ -249,7 +249,7 @@ class PodcastImportController extends BaseController
'full_name' => $fullName,
'unique_name' => slugify($fullName),
'information_url' => $podcastPerson->attributes()['href'],
'avatar' => new Image(download_file((string) $podcastPerson->attributes()['img'])),
'avatar' => download_file((string) $podcastPerson->attributes()['img']),
'created_by' => user_id(),
'updated_by' => user_id(),
]);
@ -326,7 +326,7 @@ class PodcastImportController extends BaseController
property_exists($nsItunes, 'image') && $nsItunes->image !== null &&
$nsItunes->image->attributes()['href'] !== null
) {
$episodeCover = new Image(download_file((string) $nsItunes->image->attributes()['href']));
$episodeCover = download_file((string) $nsItunes->image->attributes()['href']);
} else {
$episodeCover = null;
}
@ -402,7 +402,7 @@ class PodcastImportController extends BaseController
'full_name' => $fullName,
'unique_name' => slugify($fullName),
'information_url' => $episodePerson->attributes()['href'],
'avatar' => new Image(download_file((string) $episodePerson->attributes()['img'])),
'avatar' => download_file((string) $episodePerson->attributes()['img']),
'created_by' => user_id(),
'updated_by' => user_id(),
]);