+
+
+

Minha Nuvem Dropbox

+

Gerencie e assista seus vídeos salvos diretamente da nuvem.

+
+ +
+
+
+ +
Selecione um vídeo
+
-
-
-

Playlist

-
    - +
    +

    Playlist na Nuvem

    +
      + 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()); - } + $listFolderContents = $dropbox->listFolder('/'); + $items = $listFolderContents->getItems(); - 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; + $foundVideos = 0; + foreach ($items as $item) { + if ($item instanceof FileMetadata) { + $filename = strtolower($item->getName()); + $videoExtensions = ['.mp4', '.mov', '.avi', '.mkv', '.webm']; + $is_video = false; + foreach($videoExtensions as $ext) { + if (str_ends_with($filename, $ext)) { + $is_video = 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)
    • '; + if ($is_video) { + try { + $temporaryLink = $dropbox->getTemporaryLink($item->getPathLower()); + $link = $temporaryLink->getLink(); + echo '
    • + 🎥 ' . htmlspecialchars($item->getName()) . ' +
    • '; + $foundVideos++; + } catch (Exception $e) {} } } } + + if ($foundVideos === 0) { + echo '
    • Nenhum vídeo encontrado no Dropbox.
    • '; + } + } catch (Exception $e) { + echo '
    • Erro ao conectar com Dropbox. Verifique o token no conversor.
    • '; } } else { - echo '
    • No videos found in your Dropbox.
    • '; + echo '
    • Dropbox não configurado. Adicione um token no conversor primeiro.
    • '; } - } 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.
    • '; - } - ?> -
    + ?> +
+
+