<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: rabbery001</title>
    <description>The latest articles on DEV Community by rabbery001 (@rabbery001).</description>
    <link>https://dev.to/rabbery001</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1092394%2Feb0c04e0-3f85-4328-919b-0f2028accff1.jpg</url>
      <title>DEV Community: rabbery001</title>
      <link>https://dev.to/rabbery001</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rabbery001"/>
    <language>en</language>
    <item>
      <title>A Simple Reddit downloader with PHP</title>
      <dc:creator>rabbery001</dc:creator>
      <pubDate>Wed, 31 May 2023 06:56:58 +0000</pubDate>
      <link>https://dev.to/rabbery001/a-simple-reddit-downloader-with-php-o27</link>
      <guid>https://dev.to/rabbery001/a-simple-reddit-downloader-with-php-o27</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YIIBXPyM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nwnuvd8u2zpgurq4bya5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YIIBXPyM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nwnuvd8u2zpgurq4bya5.png" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
So, first step is to get source code of page from where we gonna extract video url, here is code how it would be done,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$uri = 'https://www.reddit.com/r/interestingasfuck/comments/130fgu1/interviewing_with_the_kkk_footage_might_disturbing/';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $uri);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3');
  $html = curl_exec($ch); // here in html page's source stored
  curl_close($ch);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the next we gonna find that video url by regex equation,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$video_regex = '/(https:\/\/v\.redd\.it\/[a-z0-9]+\/HLSPlaylist\.m3u8).*?/';
  preg_match($video_regex, $html, $videoUrl);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and then from this equation we will get video id and print output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$url = $videoUrl[0];
    $regex1 = '/https:\/\/v\.redd\.it\/(\w+)\/HLSPlaylist\.m3u8/';
    preg_match($regex1, $url, $video);
    $video_id = $video[1];
     echo '&amp;lt;video controls src="https://v.redd.it/' . $video_id . '/DASH_720.mp4"  type="video/mp4" width="320"&amp;gt;&amp;lt;/video&amp;gt;';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;here is final output with GUI &lt;a href="https://redditdownloader.org/"&gt;https://redditdownloader.org/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>laravel</category>
      <category>web</category>
      <category>curl</category>
    </item>
  </channel>
</rss>
