Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag format "id3v2.3" is not allowed on "" files, #441

Open
Gigamick opened this issue Apr 8, 2024 · 0 comments
Open

Tag format "id3v2.3" is not allowed on "" files, #441

Gigamick opened this issue Apr 8, 2024 · 0 comments

Comments

@Gigamick
Copy link

Gigamick commented Apr 8, 2024

The issue here is the error just gives me empty quotes... is there something wrong with my implementation ?

`
public function writeMetadata($token)
{

    require_once base_path('vendor/james-heinrich/getid3/getid3/getid3.php');


    $track = Track::where('token', $token)->first();
    $content = Storage::disk('s3')->get($track->key);
    $tempPath = storage_path('tempfile.mp3');

    if ($content === false) {
        // Handle error; file download failed
        Log::error("Failed to download the file");
        return;
    }

    file_put_contents($tempPath, $content);

    $tagwriter = new getid3_writetags;
    $tagwriter->filename = $tempPath;
    $tagwriter->tagformats = array('id3v2.3');

    $TagData = [
        'title' => ["The mofo title"],
        'artist' => ["Yaldi crew"],
        'album' => ["yeer maw's got a boaby"],
        'year' => ["1994"],
        'genre' => ["grunge pop"],
        'composer' => ["yer da"],
        // Add more fields as needed
    ];

    $tagwriter->tag_data = $TagData;

    // Write tags
    if (!$tagwriter->WriteTags()) {
        if (is_array($tagwriter->errors)) {
            // If errors are in an array, use implode to convert them to a string
            echo("Failed to write tags for track {$token}: ".implode(", ", $tagwriter->errors));
        } else {
            // If it's not an array, log it directly. Might need to convert to string if it's not
            echo("Failed to write tags for track {$token}: ".$tagwriter->errors);
        }
    } else {
        echo("wrote tags");
    }


    Storage::disk('s3')->put($track->key, file_get_contents($tempPath));

    // Clean up the temporary file
    try {
        unlink($tempPath);
    } catch (\Exception $e) {
        Log::error("Failed to delete the temporary file: ".$e->getMessage());
    }

}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant