Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • adaures/castopod
  • mkljczk/castopod-host
  • spaetz/castopod-host
  • PatrykMis/castopod
  • jonas/castopod
  • ajeremias/castopod
  • misuzu/castopod
  • KrzysztofDomanczyk/castopod
  • Behel/castopod
  • nebulon/castopod
  • ewen/castopod
  • NeoluxConsulting/castopod
  • nateritter/castopod-og
  • prcutler/castopod
14 results
Select Git revision
Show changes
Commits on Source (2)
# [1.0.0-alpha.78](https://code.podlibre.org/podlibre/castopod-host/compare/v1.0.0-alpha.77...v1.0.0-alpha.78) (2021-12-15)
### Bug Fixes
- **import:** add extension when downloading file without + truncate slug if too
long
([c5f18bb](https://code.podlibre.org/podlibre/castopod-host/commit/c5f18bb6dc08a758ff735454bbe9cfa45a68c09b))
# [1.0.0-alpha.77](https://code.podlibre.org/podlibre/castopod-host/compare/v1.0.0-alpha.76...v1.0.0-alpha.77) (2021-11-23) # [1.0.0-alpha.77](https://code.podlibre.org/podlibre/castopod-host/compare/v1.0.0-alpha.76...v1.0.0-alpha.77) (2021-11-23)
### Bug Fixes ### Bug Fixes
......
...@@ -11,7 +11,7 @@ declare(strict_types=1); ...@@ -11,7 +11,7 @@ declare(strict_types=1);
| |
| NOTE: this constant is updated upon release with Continuous Integration. | NOTE: this constant is updated upon release with Continuous Integration.
*/ */
defined('CP_VERSION') || define('CP_VERSION', '1.0.0-alpha.77'); defined('CP_VERSION') || define('CP_VERSION', '1.0.0-alpha.78');
/* /*
| -------------------------------------------------------------------- | --------------------------------------------------------------------
......
...@@ -131,9 +131,9 @@ class Mimes ...@@ -131,9 +131,9 @@ class Mimes
'rar' => ['application/vnd.rar', 'application/x-rar', 'application/rar', 'application/x-rar-compressed'], 'rar' => ['application/vnd.rar', 'application/x-rar', 'application/rar', 'application/x-rar-compressed'],
'mid' => 'audio/midi', 'mid' => 'audio/midi',
'midi' => 'audio/midi', 'midi' => 'audio/midi',
'mp3' => ['audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'],
'mpga' => 'audio/mpeg', 'mpga' => 'audio/mpeg',
'mp2' => 'audio/mpeg', 'mp2' => 'audio/mpeg',
'mp3' => ['audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'],
'aif' => ['audio/x-aiff', 'audio/aiff'], 'aif' => ['audio/x-aiff', 'audio/aiff'],
'aiff' => ['audio/x-aiff', 'audio/aiff'], 'aiff' => ['audio/x-aiff', 'audio/aiff'],
'aifc' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff',
...@@ -306,10 +306,10 @@ class Mimes ...@@ -306,10 +306,10 @@ class Mimes
/** /**
* Attempts to determine the best file extension for a given mime type. * Attempts to determine the best file extension for a given mime type.
* *
* @param string|null $proposedExtension - default extension (in case there is more than one with the same mime type) * @param string $proposedExtension - default extension (in case there is more than one with the same mime type)
* @return string|null The extension determined, or null if unable to match. * @return string|null The extension determined, or null if unable to match.
*/ */
public static function guessExtensionFromType(string $type, string $proposedExtension = null): ?string public static function guessExtensionFromType(string $type, string $proposedExtension = ''): ?string
{ {
$type = trim(strtolower($type), '. '); $type = trim(strtolower($type), '. ');
......
...@@ -305,11 +305,10 @@ class PodcastImportController extends BaseController ...@@ -305,11 +305,10 @@ class PodcastImportController extends BaseController
); );
$nsContent = $item->children('http://purl.org/rss/1.0/modules/content/'); $nsContent = $item->children('http://purl.org/rss/1.0/modules/content/');
$slug = slugify( $textToSlugify = $this->request->getPost('slug_field') === 'title'
$this->request->getPost('slug_field') === 'title' ? (string) $item->title
? (string) $item->title : basename((string) $item->link);
: basename((string) $item->link), $slug = slugify($textToSlugify, 185);
);
if (in_array($slug, $slugs, true)) { if (in_array($slug, $slugs, true)) {
$slugNumber = 2; $slugNumber = 2;
while (in_array($slug . '-' . $slugNumber, $slugs, true)) { while (in_array($slug . '-' . $slugNumber, $slugs, true)) {
...@@ -348,7 +347,10 @@ class PodcastImportController extends BaseController ...@@ -348,7 +347,10 @@ class PodcastImportController extends BaseController
'title' => $item->title, 'title' => $item->title,
'slug' => $slug, 'slug' => $slug,
'guid' => $item->guid ?? null, 'guid' => $item->guid ?? null,
'audio_file' => download_file((string) $item->enclosure->attributes()['url']), 'audio_file' => download_file(
(string) $item->enclosure->attributes()['url'],
(string) $item->enclosure->attributes()['type']
),
'description_markdown' => $converter->convert($itemDescriptionHtml), 'description_markdown' => $converter->convert($itemDescriptionHtml),
'description_html' => $itemDescriptionHtml, 'description_html' => $itemDescriptionHtml,
'image' => $episodeImage, 'image' => $episodeImage,
......
...@@ -11,6 +11,7 @@ declare(strict_types=1); ...@@ -11,6 +11,7 @@ declare(strict_types=1);
use CodeIgniter\Files\File; use CodeIgniter\Files\File;
use CodeIgniter\HTTP\Files\UploadedFile; use CodeIgniter\HTTP\Files\UploadedFile;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use Config\Mimes;
use Config\Services; use Config\Services;
if (! function_exists('save_media')) { if (! function_exists('save_media')) {
...@@ -41,7 +42,7 @@ if (! function_exists('save_media')) { ...@@ -41,7 +42,7 @@ if (! function_exists('save_media')) {
} }
if (! function_exists('download_file')) { if (! function_exists('download_file')) {
function download_file(string $fileUrl): File function download_file(string $fileUrl, string $mimetype = ''): File
{ {
$client = Services::curlrequest(); $client = Services::curlrequest();
...@@ -75,12 +76,15 @@ if (! function_exists('download_file')) { ...@@ -75,12 +76,15 @@ if (! function_exists('download_file')) {
'http_errors' => false, 'http_errors' => false,
]); ]);
} }
$fileExtension = pathinfo(parse_url($newFileUrl, PHP_URL_PATH), PATHINFO_EXTENSION);
$extension = $fileExtension === '' ? Mimes::guessExtensionFromType($mimetype) : $fileExtension;
$tmpFilename = $tmpFilename =
time() . time() .
'_' . '_' .
bin2hex(random_bytes(10)) . bin2hex(random_bytes(10)) .
'.' . '.' .
pathinfo(parse_url($newFileUrl, PHP_URL_PATH), PATHINFO_EXTENSION); $extension;
$tmpFilePath = WRITEPATH . 'uploads/' . $tmpFilename; $tmpFilePath = WRITEPATH . 'uploads/' . $tmpFilename;
file_put_contents($tmpFilePath, $response->getBody()); file_put_contents($tmpFilePath, $response->getBody());
......
...@@ -23,8 +23,13 @@ if (! function_exists('get_browser_language')) { ...@@ -23,8 +23,13 @@ if (! function_exists('get_browser_language')) {
} }
if (! function_exists('slugify')) { if (! function_exists('slugify')) {
function slugify(string $text): string function slugify(string $text, int $maxLength = 191): string
{ {
// trim text to the nearest whole word if too long
if (strlen($text) > $maxLength) {
$text = substr($text, 0, strrpos(substr($text, 0, $maxLength), ' '));
}
// replace non letter or digits by - // replace non letter or digits by -
$text = preg_replace('~[^\pL\d]+~u', '-', $text); $text = preg_replace('~[^\pL\d]+~u', '-', $text);
......
...@@ -89,29 +89,29 @@ ...@@ -89,29 +89,29 @@
<?= form_fieldset('', ['class' => 'flex flex-col mb-4']) ?> <?= form_fieldset('', ['class' => 'flex flex-col mb-4']) ?>
<legend><?= lang('PodcastImport.slug_field.label') ?></legend> <legend><?= lang('PodcastImport.slug_field.label') ?></legend>
<label for="link" class="inline-flex items-center"> <label for="title" class="inline-flex items-center">
<?= form_radio( <?= form_radio(
[ [
'id' => 'link', 'id' => 'title',
'name' => 'slug_field', 'name' => 'slug_field',
'class' => 'form-radio text-pine-700', 'class' => 'form-radio text-pine-700',
], ],
'link', 'title',
old('slug_field') ? old('slug_field') == 'link' : true, old('slug_field') ? old('slug_field') === 'title' : true,
) ?> ) ?>
<span class="ml-2"><?= lang('PodcastImport.slug_field.link') ?></span> <span class="ml-2"><?= lang('PodcastImport.slug_field.title') ?></span>
</label> </label>
<label for="title" class="inline-flex items-center"> <label for="link" class="inline-flex items-center">
<?= form_radio( <?= form_radio(
[ [
'id' => 'title', 'id' => 'link',
'name' => 'slug_field', 'name' => 'slug_field',
'class' => 'form-radio text-pine-700', 'class' => 'form-radio text-pine-700',
], ],
'title', 'link',
old('slug_field') && old('slug_field') == 'title', old('slug_field') && old('slug_field') === 'link',
) ?> ) ?>
<span class="ml-2"><?= lang('PodcastImport.slug_field.title') ?></span> <span class="ml-2"><?= lang('PodcastImport.slug_field.link') ?></span>
</label> </label>
<?= form_fieldset_close() ?> <?= form_fieldset_close() ?>
......
{ {
"name": "podlibre/castopod-host", "name": "podlibre/castopod-host",
"version": "1.0.0-alpha77", "version": "1.0.0-alpha78",
"type": "project", "type": "project",
"description": "Castopod Host is an open-source hosting platform made for podcasters who want engage and interact with their audience.", "description": "Castopod Host is an open-source hosting platform made for podcasters who want engage and interact with their audience.",
"homepage": "https://castopod.org", "homepage": "https://castopod.org",
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "371c6aac9ca489338bf3b3fa06ffdb21", "content-hash": "49719de3dd6af8c394ea0553e2180b5a",
"packages": [ "packages": [
{ {
"name": "brick/math", "name": "brick/math",
...@@ -494,24 +494,24 @@ ...@@ -494,24 +494,24 @@
}, },
{ {
"name": "james-heinrich/getid3", "name": "james-heinrich/getid3",
"version": "v2.0.0-beta3", "version": "v2.0.0-beta4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/JamesHeinrich/getID3.git", "url": "https://github.com/JamesHeinrich/getID3.git",
"reference": "5515a2d24667c3c0ff49fdcbdadc405c0880c7a2" "reference": "5ad79104e937e7d9c8a9141a97e1f063dd1123f8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/JamesHeinrich/getID3/zipball/5515a2d24667c3c0ff49fdcbdadc405c0880c7a2", "url": "https://api.github.com/repos/JamesHeinrich/getID3/zipball/5ad79104e937e7d9c8a9141a97e1f063dd1123f8",
"reference": "5515a2d24667c3c0ff49fdcbdadc405c0880c7a2", "reference": "5ad79104e937e7d9c8a9141a97e1f063dd1123f8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.4.0" "php": ">=5.4.0"
}, },
"require-dev": { "require-dev": {
"jakub-onderka/php-parallel-lint": "^0.9 || ^1.0", "php-parallel-lint/php-parallel-lint": "^1.0",
"phpunit/phpunit": "^4.8|^5.0" "phpunit/phpunit": "^4.8 || ^5.0 || ^6.1 || ^7.5 || ^8.5"
}, },
"suggest": { "suggest": {
"ext-SimpleXML": "SimpleXML extension is required to analyze RIFF/WAV/BWF audio files (also requires `ext-libxml`).", "ext-SimpleXML": "SimpleXML extension is required to analyze RIFF/WAV/BWF audio files (also requires `ext-libxml`).",
...@@ -562,9 +562,9 @@ ...@@ -562,9 +562,9 @@
"keywords": ["audio", "codecs", "id3", "metadata", "tags", "video"], "keywords": ["audio", "codecs", "id3", "metadata", "tags", "video"],
"support": { "support": {
"issues": "https://github.com/JamesHeinrich/getID3/issues", "issues": "https://github.com/JamesHeinrich/getID3/issues",
"source": "https://github.com/JamesHeinrich/getID3/tree/2.0" "source": "https://github.com/JamesHeinrich/getID3/tree/v2.0.0-beta4"
}, },
"time": "2020-07-21T08:15:44+00:00" "time": "2021-10-06T16:23:45+00:00"
}, },
{ {
"name": "kint-php/kint", "name": "kint-php/kint",
...@@ -7465,5 +7465,5 @@ ...@@ -7465,5 +7465,5 @@
"php": "^8.0" "php": "^8.0"
}, },
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "2.0.0" "plugin-api-version": "2.1.0"
} }
{ {
"name": "castopod-host", "name": "castopod-host",
"version": "1.0.0-alpha.77", "version": "1.0.0-alpha.78",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "castopod-host", "name": "castopod-host",
"version": "1.0.0-alpha.77", "version": "1.0.0-alpha.78",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"dependencies": { "dependencies": {
"@amcharts/amcharts4": "^4.10.17", "@amcharts/amcharts4": "^4.10.17",
{ {
"name": "castopod-host", "name": "castopod-host",
"version": "1.0.0-alpha.77", "version": "1.0.0-alpha.78",
"description": "Castopod Host is an open-source hosting platform made for podcasters who want engage and interact with their audience.", "description": "Castopod Host is an open-source hosting platform made for podcasters who want engage and interact with their audience.",
"private": true, "private": true,
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
......