• Resolved hluu

    (@hluu)


    hello,

    I have Postie installed and working. I can post by email. Yay!

    But what I really need is to publish my podcast episodes. I am using the powerpress plugin (my files are not hosted on blubrry, I am using the free stats). How do I insert the media URL so it is recognized as such. If I insert

    [powerpress url=”urltomediafile.mp3″]

    I get the powerpress embedded player, but in the rss feed it just shows up as plain text. There’s no media URL associated, hence it is not recognized as a podcast episode.

    thanks in advance for any pointer

Viewing 8 replies - 1 through 8 (of 8 total)
  • Instead of using the shortcode, put the full URL to the mp3 file in the Podcast Episode box in the post editor (towards the bottom) in the media URL box. That will put it in the feed and generate a player on the post (depending on how you have the website tab in PowerPress settings filled out.

    For complete setup and use instructions, see this video: https://youtu.be/4AV5HPvwRv8

    Thread Starter hluu

    (@hluu)

    Thank you for replying. I know how to do it in the WP editor.

    I’m trying to do it via Postie (post by email). I need to do the equivalent of adding the media URL field in the editor screen — via email.

    Plugin Author Wayne Allen

    (@wayneallen-1)

    Try going the the Video and Audio Postie settings tab and change the audio template to:
    [powerpress url="{FILELINK}"]

    Thread Starter hluu

    (@hluu)

    Thank you, but I think I went down the wrong path with the [powerpress] shortcode, since that only affects what shows up visually, ie, it will show a media player in the post.

    What I need is to be able to attach a URL to a media file so that it will show up in the feed as an RSS enclosure and be recognized as a podcast episode.

    https://en.wikipedia.org/wiki/RSS_enclosure

    Internally, this isn’t in the post table, but the postmeta table with meta_key ‘enclosure’

    • This reply was modified 8 years, 4 months ago by hluu.
    Plugin Author Wayne Allen

    (@wayneallen-1)

    You can create an AddOn that will populate the correct meta values. See http://postieplugin.com/extending/

    Thread Starter hluu

    (@hluu)

    Ok, I hope I can do this, thanks πŸ™‚

    Thread Starter hluu

    (@hluu)

    This turned out pretty straightforward, as wordpress API makes it easy. Posting code here. Hope this’ll help someone.

    <?php
    
    /*
        Postie add-on to extract [enclosure] short code and insert into meta table the way powerpress does it
        Take, for example,
            [enclosure type="audio/mpeg" url="http://feeds.soundcloud.com/stream/9966888"
                    length="854664" duration="00:23:11"]/>
        and add_post_meta 'enclosure' with value
    
        http://feeds.soundcloud.com/stream/9966888
        854664
        audio/mpeg
        a:1:{s:8:"duration";s:8:"00:23:11";}
    
    */
    
    $enclosure = '';
    
    function extract_enclosure($post) {
        //do something here like update $post['post_content']
        global $enclosure;
    
        // look for a line containing
        // [enclosure ....]
        //
        // may have spaces or > before and spaces after, but must be on line by itself
        $re = '/(\R+|^)[ >]*\[enclosure (.+)?\] *(\R+|$)/m';
    
        if (preg_match($re, $post['post_content'], $m)) {
            // use SimpleXMLElement to parse attribute
            $xml = new SimpleXMLElement("<element {$m[2]} />");
            if ($xml) {
                $enclosure =
                    $xml[0]['url'] . "\n" .
                    $xml[0]['length'] . "\n" .
                    $xml[0]['type'] . "\n" .
                    'a:1:{s:8:"duration";s:8:"' . $xml[0]['duration'] . '";}';
            }
            // replace multiple preceding and trailing \n with 1
            $nl = $m[1] ? "\n" : '';
            $nl .= $m[2] ? "\n" : '';
            $post['post_content'] = preg_replace($re,  $nl, $post['post_content'], 1);
        }
        return $post;
    }
    
    function insert_enclosure($post) {
        global $enclosure;
    
        if ($enclosure) {
            add_post_meta($post['ID'], 'enclosure', $enclosure, true);
        }
        return $post;
    }
    
    add_filter('postie_post_before', 'extract_enclosure');
    add_filter('postie_post_after', 'insert_enclosure');
    
    ?>
    Plugin Author Wayne Allen

    (@wayneallen-1)

    Nice. You could move all the logic from insert_enclosure() into extract_enclosure(). $post[‘ID’] exists and is valid during postie_post_before

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Powerpress media file’ is closed to new replies.