Back to Dashboard

My Video Cloud

Playlist

    query("SELECT dropbox_token FROM streams WHERE dropbox_token IS NOT NULL AND dropbox_token != '' ORDER BY created_at DESC LIMIT 1"); $result = $stmt->fetch(); $token = $result ? $result['dropbox_token'] : null; } catch (PDOException $e) { $token = null; error_log("Database error fetching token: " . $e->getMessage()); } if ($token) { try { $app = new App("", "", $token); $dropbox = new Client($app); $files = $dropbox->listFolder('/'); $items = $files->getItems(); if (count($items) > 0) { foreach ($items as $item) { $metadata = $item->getMetadata(); if ($metadata instanceof \Dropbox\Models\FileMetadata) { // Check if it's a video file based on extension $videoExtensions = ['.mp4', '.mov', '.avi', '.mkv', '.webm']; $filename = strtolower($metadata->getName()); $shouldDisplay = false; foreach($videoExtensions as $ext) { if (str_ends_with($filename, $ext)) { $shouldDisplay = true; break; } } if ($shouldDisplay) { try { // Get a temporary link for the file $temporaryLink = $dropbox->getTemporaryLink($metadata->getPathLower()); $link = $temporaryLink->getLink(); echo '
  • ' . htmlspecialchars($metadata->getName()) . '
  • '; } catch (Exception $e) { // Could not get a temporary link for some reason error_log("Dropbox API error getting temporary link: " . $e->getMessage()); // Optionally, display an error for this specific file echo '
  • ' . htmlspecialchars($metadata->getName()) . ' (Error)
  • '; } } } } } else { echo '
  • No videos found in your Dropbox.
  • '; } } catch (Exception $e) { error_log("Dropbox API error: " . $e->getMessage()); if(str_contains($e->getMessage(), 'invalid_access_token')) { echo '
  • Error connecting to Dropbox: The access token is invalid. Please go to the converter page and re-enter a valid token.
  • '; } else { echo '
  • Error connecting to Dropbox.
  • '; } } } else { echo '
  • Dropbox is not configured. Please go to the converter page, provide a token, and upload a video first.
  • '; } ?>