So if file name contains spaces video wont be transcoded. I suggest to use transliteration by video ftp field.

Comments

mibfire’s picture

i solved myself:

/* transliteration module own implement */

function bandg_transliteration_clean_filename($filename, $source_langcode = NULL) {
$filename = transliteration_get($filename, '', $source_langcode);
// Replace whitespace.
$filename = str_replace(' ', '-', $filename);
// Remove remaining unsafe characters.
$filename = preg_replace('![^0-9A-Za-z_.-]!', '', $filename);
// Force lowercase to prevent issues on case-insensitive file systems.
if (variable_get('transliteration_file_lowercase', TRUE)) {
$filename = strtolower($filename);
}
return $filename;
}

/* i call this function from own node-form(video) submit function */

function bngi_transliteration_retroactive() {
module_load_include('inc', 'transliteration', 'transliteration.admin');
$count = 0;
$errors = array();
$result = db_query(transliteration_file_query());

while ($file = db_fetch_object($result)) {
if (!file_exists('./'. $file->filepath)) {
// Missing file.
$errors[] = $file->filepath;
continue;
}

// Sanitize file name.
$filename_org = basename($file->filepath);
$filename = transliteration_clean_filename($filename_org);
// Build destination path.
$destination = dirname($file->filepath) . '/' . $filename;

$filename_conv = bandg_transliteration_clean_filename($filename_org);

// Rename and update the file record accordingly.
if (file_move($file->filepath, $destination, FILE_EXISTS_RENAME)) {
db_query("UPDATE {files} SET filepath = '%s', filename = '%s' WHERE fid = %d", $file->filepath, $filename_conv, $file->fid);
$count++;
}
else {
$errors[] = $file->filepath;
}
}

if ($errors) {
$message = t('Not all file names could be converted. The following files could not be accessed and have been ignored:');
$message .= theme('item_list', $errors);
drupal_set_message($message, 'error');
}
else {
drupal_set_message(t('@filenames have been successfully transliterated.', array('@filenames' => format_plural($count, '1 file name', '@count file names'))));
}

// Flush page cache.
cache_clear_all();
}

heshanlk’s picture

If you can provide a patch then it would be better.

Jorrit’s picture

Status:Active» Postponed (maintainer needs more info)

What problem do you experience when filenames contain spaces?

Jorrit’s picture

Status:Postponed (maintainer needs more info)» Closed (works as designed)

Closed because of lack of response.

dynamicdan’s picture

Project:Video» Transliteration
Version:6.x-4.1-rc6» 7.x-3.0
Component:Code» Documentation
Category:bug» task
Priority:Critical» Normal
Status:Closed (works as designed)» Active

I came across this issue.. it is to do with characters corrupting file names...

I had 11 files that I couldn't transliterate because PHP couldn't find the file. That's because the file name was garbled on my Mac OS X system after pulling them down from some kind of *nix system.

I believe the only reason the above code is needed is due to this line:

<?php
$filename
= preg_replace('![^0-9A-Za-z_.-]!', '', $filename);
?>

It would remove any unknown characters before saving/uploading a file and thus avoid any corrupted file naming problems.

This information should be documented in the transliteration module. Not here. Updating issue.

dynamicdan’s picture

Title:Video ftp doesnt convert the attached file name before transcoding» Document files changing name when they are moved between file systems.
Category:task» bug

FYI, the UI for this module makes it look like everything should work. Perhaps this is a bug?

amateescu’s picture

Status:Active» Postponed (maintainer needs more info)

I don't understand what Transliteration has to do with moving files between filesystems. Can you be more precise in specifying what exactly is the bug in this module?

amateescu’s picture

Status:Postponed (maintainer needs more info)» Closed (cannot reproduce)

Closing until we get further debugging info here, or what actually needs to be documented.

dynamicdan’s picture

@amateescu
File names look different on different file systems (and in diff FTP/terminal apps).

You need the file names to test I guess... don't really have them anymore though :(
Will try and post more info when I get it.