Automatically link youtube videos

You could try with a php function the following:

<?php
function getYouTubeVideosByTag($tag, $maxResults = 6) {
    $apiKey = '[your youtube API key]';
    $channelId = '[your-youtube-channel-ID';

    // Forza formato hashtag
    $query = urlencode('#' . $tag);

    $url = "https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&order=date&maxResults=$maxResults&q=$query&channelId=$channelId&key=$apiKey";

    $response = file_get_contents($url);

    if ($response === FALSE) {
        return [];
    }

    $data = json_decode($response, true);

    $videos = [];

    if (!empty($data['items'])) {
        foreach ($data['items'] as $item) {
            if (!isset($item['id']['videoId'])) continue;

            $videos[] = [
                'title' => $item['snippet']['title'],
                'videoId' => $item['id']['videoId'],
                'description' => $item['snippet']['description'],
                // 'thumbnail' => $item['snippet']['thumbnails']['medium']['url']
            ];
        }
    }

    return $videos;
}
?>

Obviously you have to link this function in every web page you want links your videos, and in these pages you can call that function by a code like this:

<?php
if (!empty($youtubetag)) {

    if (is_array($youtubetag)) {
        $query = implode(' OR ', array_map(fn($t) => '#' . $t, $youtubetag));
        $videos = getYouTubeVideos($query, 5);
    } else {
        $videos = getYouTubeVideosByTag($youtubetag, 3);
    }

    if (!empty($videos)) {
        ?>

        <section class="youtube-videos">
        <h2>🎙️ Our podcast (YouTube)</h2>

            <ul>
                <?php foreach ($videos as $video): ?>
                    <li class="podcast">🎙️
                        <a href="https://www.youtube.com/watch?v=<?= $video['videoId'] ?>"><strong><?= htmlspecialchars($video['title']) ?></strong></a>:
                       <?= htmlspecialchars(substr($video['description'], 0, 120), ENT_QUOTES | ENT_HTML5, 'UTF-8', false) ?>
                    </li>
                <?php endforeach; ?>
            </ul>
        </section>

        <?php
    }
}
?>

Finally, you should define, possibly in the head of each php page, where you want to link youtube videos, the variable $youtubetag:

$youtubetag="my tag";
or 
$youtubetag="['mytag1', 'mytag2']";

semantic tags

Html5 helps to use semantic tags, but only in some cases.

Dates

I.g. for a date you can use <time>

    <p>La conferenza si terrà il <time datetime="2025-11-14">14 novembre 2025</time>.</p>

Books

Far more complicated is the way for the books. There is not a tag such as <book>. Unfortunately, the Internet is not for the truth, but for commercial purposes, so you have to follow a very long and annoying way:

     <h1>List of Books</h1>

    <div itemscope itemtype="http://schema.org/Book">
        <h2 itemprop="name">The Great Gatsby</h2>
        <img src="cover-gatsby.jpg" alt="Cover of The Great Gatsby" itemprop="image">
        <p itemprop="author">F. Scott Fitzgerald</p>
        <p itemprop="description">The Great Gatsby is a novel written by F. Scott Fitzgerald and published in 1925. The story is set in 1922 during the Jazz Age and the economic prosperity of the United States.</p>
    </div>

    <div itemscope itemtype="http://schema.org/Book">
        <h2 itemprop="name">1984</h2>
        <img src="cover-1984.jpg" alt="Cover of 1984" itemprop="image">
        <p itemprop="author">George Orwell</p>
        <p itemprop="description">1984 is a dystopian novel written by George Orwell and published in 1949. The story is set in a future dystopia where the totalitarian government controls every aspect of citizens' lives.</p>
    </div>

    <div itemscope itemtype="http://schema.org/Book">
        <h2 itemprop="name">Moby Dick</h2>
        <img src="cover-moby-dick.jpg" alt="Cover of Moby Dick" itemprop="image">
        <p itemprop="author">Herman Melville</p>
        <p itemprop="description">Moby Dick is a novel written by Herman Melville and published in 1851. The story follows the obsessive quest of Captain Ahab to hunt down the white whale, Moby Dick.</p>
    </div>

another example:

<tr itemscope itemtype="http://schema.org/Book"><td><span itemprop="name">Traumdeutung</span></td>
<td><span itemprop="alternativeHeadline"> L'interpretazione dei sogni</span></td><td><span itemprop="datePublished" content="1900">1900</span></td></tr>
<tr itemscope itemtype="http://schema.org/Book"><td><span itemprop="name">Zur Psychopathlogie des Altagslebens</span></td>
<td><span itemprop="alternativeHeadline"> Psicopatologia della vita quotidiana</span></td><td><span itemprop="datePublished" content="1901">1901</span></td></tr>

other book’s tags

<span itemprop=”locationCreated”>

<span itemprop=”bookEdition”> (for Edition)

<span itemprop=”author”> (for Author)

Movies

You could use a code like the following:

<div itemscope itemtype="http://schema.org/Movie">
  <h1 itemprop="name">The Godfather</h1>
  <h2 itemprop="alternateName">Il Padrino</h2>
  <img itemprop="image" src="https://example.com/locandina_il_padrino.jpg" alt="Locandina del film Il Padrino">
  <p>Regista: <span itemprop="director">Francis Ford Coppola</span></p>
  <p>Data di rilascio: <span itemprop="releaseDate">15 marzo 1972</span></p>
</div>
more here.

include wordpress category (or tag) posts in a website

  • You can install wordpress in a subdirectory of your website, in localhost as well.
  • Afterward you can embed the content (or the link) of your wordpress posts in your php pages using a code like the following:
<?php 
/* the path of your wordpress subfolder with the file, required, "wp-blog-header.php" */
require("$root/wordpress/wp-blog-header.php");
//get_header(); [you can omit this row, if you want embed the wp posts in your page having already header and styles]
?>


<?php
// Get the last 200 posts of a given category: 
//in this case the 565 one (=office).
global $post;
$args = array('posts_per_page' => 200,  'category' => 565 );
$myposts = get_posts( $args );

foreach( $myposts as $post ) :	setup_postdata($post); ?>
<h2><?php the_title(); ?></h2>
<p><?php the_content(); ?></p>
// the following code is to put a link: you could choose to don't add it, or, on the contrary, to put only it
<a href="<?php the_permalink() ?>" rel="bookmark" 
title="Permanent Link to <?php the_title_attribute(); ?>">
<?php the_title(); ?></a><br />
<?php endforeach; ?>
  • if you want embed in your pages tag posts instead of category posts you can use this code

$args = array('posts_per_page' => 100, 'tag' => 'css' );

Further info here.

QuodLibet

perché è un programma utile

Si tratta di un player audio in Python: come player non è granché, Amarok è sicuramente meglio. Però Quodlibet è abbinato a Ex-Falso, un manipolatore di tags più potente di Amarok. Infatti Ex-Falso legge e e scrive i tags ID3v2, come Amarok non riesce a fare, e può scrivere e leggere anche tags opzionali. Come potete vedere nella schermata, ho aggiunto “tonalita”, come non avrei potuto fare con Amarok.

[Image]

possibile problema

Il programma non parte e il messaggio di errore è: “The audio output pipeline ‘gconfaudiosink profile = music’ could not be created”

soluzione

Per farlo partire può allora essere necessario aggiungere al file config le seguenti righe:

  • “alsasink device = hw:1” nella sezione [settings]
  • “gst_pipeline = alsasink” nella sezione [player]

meta tags

Quale che si il tipo di media a cui volete aggiungere un tag, è di norma preferibile che il (meta)tag sia incorporato nel file multimediale.
In questo modo, se si dovesse reinstallare il programma con cui essi vengono letti, o trasferire i files da un PC all’altro, ad esempio, non si correrebbe il rischio di aver lavorato invano.
Amarok ad esempio lo fa, automaticamente, per i tags classici (nome artista, titolo, anno, genere ecc.), ma ovviamente non lo fa per voci come “score”, o “rating” che vengono aggiunte a un suo database esterno ai files musicali così taggati.
Digikam lascia scegliere all’utente: occorre dirgli, nei Settings, che gli “image tags” siano trattati come “Keywords tags” e con ciò incorporati nel file immagine.