<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Python on davepedu.com</title><link>https://davepedu.com/tags/python/</link><description>Recent content in Python on davepedu.com</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><managingEditor>dave@davepedu.com (dave)</managingEditor><webMaster>dave@davepedu.com (dave)</webMaster><lastBuildDate>Thu, 28 Feb 2019 00:00:00 +0000</lastBuildDate><atom:link href="https://davepedu.com/tags/python/index.xml" rel="self" type="application/rss+xml"/><item><title>pyods: open directory scraper</title><link>https://davepedu.com/projects/2019/02/28/pyods-open-directory-scraper/</link><pubDate>Thu, 28 Feb 2019 00:00:00 +0000</pubDate><author>dave@davepedu.com (dave)</author><guid>https://davepedu.com/projects/2019/02/28/pyods-open-directory-scraper/</guid><description>&lt;p&gt;I&amp;rsquo;m a long-time reader and participant of the Reddit.com Subreddits
&lt;a href="https://old.reddit.com/r/DataHoarder/"&gt;/r/Datahoarder&lt;/a&gt; and
&lt;a href="https://old.reddit.com/r/opendirectories/"&gt;/r/OpenDirectories&lt;/a&gt;. As both of these deal with retrieval and archival of
data and information, wget is a wildly popular tool within these communities.&lt;/p&gt;
&lt;p&gt;For the unfamiliar, an &amp;ldquo;open directory&amp;rdquo; is a directory on a website where there is no index file. Since there&amp;rsquo;s no
content to serve, most web servers will generate a page showing a listing of files on the server. Wget is a command-line
tool for making various types of HTTP and FTP requests. Specifically, wget is specialized for content mirroring and it
works nicely with open directories. That is, following links at the target URL to discover additional links to download
with the end goal of downloading an identical mirror of the remote site.&lt;/p&gt;</description><content>&lt;p&gt;I&amp;rsquo;m a long-time reader and participant of the Reddit.com Subreddits
&lt;a href="https://old.reddit.com/r/DataHoarder/"&gt;/r/Datahoarder&lt;/a&gt; and
&lt;a href="https://old.reddit.com/r/opendirectories/"&gt;/r/OpenDirectories&lt;/a&gt;. As both of these deal with retrieval and archival of
data and information, wget is a wildly popular tool within these communities.&lt;/p&gt;
&lt;p&gt;For the unfamiliar, an &amp;ldquo;open directory&amp;rdquo; is a directory on a website where there is no index file. Since there&amp;rsquo;s no
content to serve, most web servers will generate a page showing a listing of files on the server. Wget is a command-line
tool for making various types of HTTP and FTP requests. Specifically, wget is specialized for content mirroring and it
works nicely with open directories. That is, following links at the target URL to discover additional links to download
with the end goal of downloading an identical mirror of the remote site.&lt;/p&gt;
&lt;p&gt;For the most part, wget excels at doing this. It&amp;rsquo;s been around for decades and is supported on nearly every operating
system, is easy to find information about online, and is generally bug free.&lt;/p&gt;
&lt;p&gt;However, wget suffers from a design flaw - its single threaded operation.&lt;/p&gt;
&lt;p&gt;Meet Pyods - the modern, Python, Open Directory, Scraper:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-"&gt;$ pyods --help
usage: pyods [-h] [-u URL] [-o OUTPUT_DIR] [-p PARALLEL] [-c] [-d DELAY]
[-e EXCLUDE [EXCLUDE ...]] [-f EXCLUDE_FROM] [-v]
Open directory scraper
optional arguments:
-h, --help show this help message and exit
-u URL, --url URL url to scrape
-o OUTPUT_DIR, --output-dir OUTPUT_DIR
destination for downloaded files
-p PARALLEL, --parallel PARALLEL
number of downloads to execute in parallel
-c, --clobber clobber existing files instead of resuming
-d DELAY, --delay DELAY
delay between requests
-e EXCLUDE [EXCLUDE ...], --exclude EXCLUDE [EXCLUDE ...]
exclude patterns
-f EXCLUDE_FROM, --exclude-from EXCLUDE_FROM
exclude patterns from file
-v, --verbose enable info logging&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Pyods was written, in Python 3, from the ground up with speed and mirroring in mind. In contrast with wget, Pyods
downloads many URLs in parallel. The options in the help text above show off Pyods&amp;rsquo; other capabilities such as excluding
URLs, adding delay between requests, etc.&lt;/p&gt;
&lt;p&gt;An example invocation might look like:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-"&gt;pyods -u http://example.com/some_open_directory/ -o ./output -p 10 --delay 5&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This example would use 10 parallel downloads with a delay of 5 seconds between each HTTP requests.&lt;/p&gt;
&lt;p&gt;I intend to release this on Pypi eventually. But for now, Pyods is available on my git instance. Happy scraping!&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Source code: &lt;a href="https://git.davepedu.com/dave/pyods"&gt;https://git.davepedu.com/dave/pyods&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;</content></item><item><title>internet radio DVR</title><link>https://davepedu.com/projects/2014/08/30/internet-radio-dvr/</link><pubDate>Sat, 30 Aug 2014 00:00:00 +0000</pubDate><author>dave@davepedu.com (dave)</author><guid>https://davepedu.com/projects/2014/08/30/internet-radio-dvr/</guid><description>&lt;p&gt;Anyone who remembers watching cable TV also remembers the DVR - Digital Video Recorder - a device that lets you record
live TV and save it for later playback. It&amp;rsquo;s useful for catching episodes of shows that air when you are busy or
sporting events overseas that air late at night for your timezone.&lt;/p&gt;
&lt;p&gt;Well, I listen to a handful of shows that only appear on live internet radio, and I wanted a similar way to record and
play them back later. So, I wrote this application.&lt;/p&gt;</description><content>&lt;p&gt;Anyone who remembers watching cable TV also remembers the DVR - Digital Video Recorder - a device that lets you record
live TV and save it for later playback. It&amp;rsquo;s useful for catching episodes of shows that air when you are busy or
sporting events overseas that air late at night for your timezone.&lt;/p&gt;
&lt;p&gt;Well, I listen to a handful of shows that only appear on live internet radio, and I wanted a similar way to record and
play them back later. So, I wrote this application.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://davepedu.com/projects/2014/08/30/internet-radio-dvr/img/streamrecord_hu_dc1e25b48aa9dd1d.png" alt="Screenshot"/&gt;&lt;/p&gt;
&lt;p&gt;This application provides a web interface where you may configure audio stream URLs and the schedules at which they
should be recorded. Each recording is saved as an MP3 file, and an RSS feed that can be consumed by any Podcast player
app provides easy access.&lt;/p&gt;
&lt;p&gt;Under the hood, this application uses FFmpeg to do most of the media recording and manipulation.&lt;/p&gt;
&lt;p&gt;Source code is available on my Git instance:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Base application: &lt;a href="https://git.davepedu.com/dave/streamrecord"&gt;https://git.davepedu.com/dave/streamrecord&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Docker image: &lt;a href="https://git.davepedu.com/dave/docker-streamrecord"&gt;https://git.davepedu.com/dave/docker-streamrecord&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;</content></item></channel></rss>