PHP Code:
<?php
function TSUEPlugin_Plex_Brezplacni_Filmi($pluginPosition = "", $pluginOptions = array()) {
global $TSUE;
// Nastavitve za Plex strenik
$plexUrl = "http://<IP naslov>:32400";
$token = "<tvoj_avtorizacijski_eton>";
$librarySection = "Movies"; // Ime sekcije v tvoji Plex knjinici
// API URL za pridobitev filmov
$apiUrl = "{$plexUrl}/library/sections/{$librarySection}/all?X-Plex-Token={$token}";
// Pridobivanje podatkov iz Plex API-ja
$response = file_get_contents($apiUrl);
if ($response === FALSE) {
return "Napaka pri pridobivanju podatkov iz Plexa.";
}
$data = simplexml_load_string($response);
// Filtriranje filmov z oznako 'brezplačno'
$brezplacniFilmi = [];
foreach ($data->Video as $video) {
if (strpos($video->Tag, 'brezplačno') !== false) {
$brezplacniFilmi[] = $video;
}
}
// Generiranje HTML za prikaz filmov
$moviesHtml = '<div class="plex-brezplacni-filmi-container">';
foreach ($brezplacniFilmi as $film) {
$title = htmlspecialchars($film->Title);
$posterUrl = "{$plexUrl}/photo/:/transcode?url={$film->thumb}&width=500&height=750";
$rating = number_format($film->Rating, 1);
$releaseDate = date('d M Y', strtotime($film->Year));
$moviesHtml .= '<div class="movie">';
$moviesHtml .= '<img src="' . $posterUrl . '" alt="' . $title . '">';
$moviesHtml .= '<div class="movie-info">';
$moviesHtml .= '<div class="movie-rating">' . $rating . '</div>';
$moviesHtml .= '<h3>' . $title . '</h3>';
$moviesHtml .= '<p>Datum izida: ' . $releaseDate . '</p>';
$moviesHtml .= '</div></div>';
}
$moviesHtml .= '</div>';
return $moviesHtml;
}
?>
And CSS
PHP Code:
.plex-brezplacni-filmi-container {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
gap: 20px;
margin: 20px auto;
background-color: #343a40;
padding: 30px;
border-radius: 12px;
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.4), 0 0 20px rgba(0, 0, 0, 0.6);
max-width: 1200px;
}
.plex-brezplacni-filmi-container .movie {
background: linear-gradient(145deg, #343a40, #495057);
padding: 20px;
width: calc(25% - 20px);
border-radius: 12px;
box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2);
text-align: center;
transition: transform 0.2s ease, box-shadow 0.3s ease;
display: flex;
flex-direction: column;
height: 380px;
position: relative;
overflow: hidden;
}
.plex-brezplacni-filmi-container .movie:hover {
transform: translateY(-5px);
box-shadow: 4px 8px 20px rgba(0, 0, 0, 0.3);
}
.plex-brezplacni-filmi-container .movie img {
width: 100%;
height: 75%;
object
::contentReference[oaicite:51]{index=51}
Install:
🔧 Steps to Customize Plex Free Movies Plugin
1. Obtaining Access to the Plex API
To access the Plex API, you will need the following information:
Plex Server URL: This is usually something like this: http://<IP address>:32400.
Authorization Token: You can obtain this by logging into your Plex account and using the developer tools in your browser to obtain this token.
The Plex API provides access to various information in your library, including metadata for movies, series, and other content.
2. Searching for Free Movies
Since Plex does not offer a direct filter for "free" movies, we can use the following approaches to search:
Using Tags: If you used tags, such as free, when adding movies to your library, we can use these tags to filter the movies.
Using Categories: If you have movies categorized into different categories, we can search within specific categories that contain free movies.
3. Customizing the PHP plugin
The plugin can be customized to display movies from your Plex library that meet certain criteria (e.g., free tag)