<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/rss-style.xsl" type="text/xsl"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	     xmlns:dc="http://purl.org/dc/elements/1.1/"
	   xmlns:atom="http://www.w3.org/2005/Atom"
	     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	  xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>bittorrent &#8211; Terence Eden’s Blog</title>
	<atom:link href="https://shkspr.mobi/blog/tag/bittorrent/feed/" rel="self" type="application/rss+xml" />
	<link>https://shkspr.mobi/blog</link>
	<description>Regular nonsense about tech and its effects 🙃</description>
	<lastBuildDate>Wed, 13 Nov 2024 07:54:44 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://shkspr.mobi/blog/wp-content/uploads/2023/07/cropped-avatar-32x32.jpeg</url>
	<title>bittorrent &#8211; Terence Eden’s Blog</title>
	<link>https://shkspr.mobi/blog</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title><![CDATA[Mobile Bit Torrent]]></title>
		<link>https://shkspr.mobi/blog/2011/11/mobile-bit-torrent/</link>
					<comments>https://shkspr.mobi/blog/2011/11/mobile-bit-torrent/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Sun, 13 Nov 2011 17:15:40 +0000</pubDate>
				<category><![CDATA[mobile]]></category>
		<category><![CDATA[bit torrent]]></category>
		<category><![CDATA[bittorrent]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery mobile]]></category>
		<category><![CDATA[NaBloPoMo]]></category>
		<category><![CDATA[torrent]]></category>
		<guid isPermaLink="false">http://shkspr.mobi/blog/?p=4579</guid>

					<description><![CDATA[This is a project I developed for OTA11 - but didn&#039;t feel confident showing it off.  Not least because I was one of the competition judges!  Preamble       Many people download BitTorrent files.     There are no BitTorrent search engines which are mobile friendly.     Users have to try to navigate non-mobile-optimised websites.     This is slow, inefficient, and may cost the user money in…]]></description>
										<content:encoded><![CDATA[<p>This is a project I developed for <a href="https://web.archive.org/web/20111012045423/http://overtheair.org/blog/2011/09/29/ota11-hackday-categories-prizes/">OTA11</a> - but didn't feel confident showing it off.  Not least because I was one of the competition judges!</p>

<h2 id="preamble"><a href="https://shkspr.mobi/blog/2011/11/mobile-bit-torrent/#preamble">Preamble</a></h2>

<ul>
    <li>Many people download BitTorrent files.</li>
    <li>There are no BitTorrent search engines which are mobile friendly.</li>
    <li>Users have to try to navigate non-mobile-optimised websites.</li>
    <li>This is slow, inefficient, and may cost the user money in bandwidth charges.</li>
    <li>People who run Bit Torrent sites are often sued.</li>
</ul>

<h2 id="the-problem"><a href="https://shkspr.mobi/blog/2011/11/mobile-bit-torrent/#the-problem">The Problem</a></h2>

<p>BitTorrent search engines have a nasty habit of being sued (not something I want to happen to me!)</p>

<p>Lawsuits arrive based, usually, on one of the following factors:</p>

<ul>
    <li>The site is hosting material which infringes a complainant's copyright.</li>
    <li>The site operates a tracker which tells users how to access copyrighted material without permission.</li>
    <li>The site distributes .torrent files which tell users how to access trackers.</li>
    <li>The site operates a search engine for Bit Torrent files.</li>
</ul>

<h2 id="the-challenge"><a href="https://shkspr.mobi/blog/2011/11/mobile-bit-torrent/#the-challenge">The Challenge</a></h2>

<p>Is it possible to create a mobile friendly torrent search engine which neither hosts, distributes, nor searches for .torrent files?</p>

<p>This is how the usual client / server relationship works</p>

<pre>     +------------+           +------------+          +------------+
     |Browser     |           |Site        |          |Server      |
     +-----+------+           +------+-----+          +------------+
           |                         |                      +
           | Request for HTML page   |                      |
           +------------------------&gt;|                      |
           |                         |Search Request        |
           |                         +---------------------&gt;|
           |                         |                      |
           |                         |                      |
           |                         |  Search Response     |
           | Generated page sent     |&lt;--------------------+|
           |&lt;-----------------------+|                      |
</pre>

<p>The browser asks the torrent site, the torrent site asks a search engine, the search engine responds to the site, and the site returns a page to the user's browser.</p>

<p>This opens the site owner up to all sorts of risks.  She knows what her users are searching for and she knows what response the torrent provider is sending.</p>

<p>Is there a way around this?  Well, using <a href="http://jquerymobile.com/">jQuery Mobile</a>, I believe there is.</p>

<pre>     +------------+           +------------+          +------------+
     |Browser     |           |Site        |          |Server      |
     +-----+------+           +------+-----+          +-----+------+
           |                         |                      |
           | Request for HTML page   |                      |
           +------------------------&gt;|                      |
           |                         |                      |
           |                         |                      |
           | Generated page sent     |                      |
           |&lt;------------------------+                      |
           |                                                |
           |                                                |
           | Search request direct to search engine         |
           +-----------------------------------------------&gt;|
           |                                                |
           |                                                |
           |      Response sent directly to phone browser   |
           |&lt;-----------------------------------------------+</pre>

<p>Here's what happens:</p>

<ol>
    <li>The user's mobile browser requests the search page.</li>
    <li>The site delivers the search page to the browser.</li>
    <li>User types "Ubuntu" into the search box and hits "search".</li>
    <li>The text "Ubuntu" is <strong>not sent to the site</strong>!</li>
    <li>jQuery Mobile "intercepts" the request.</li>
    <li>The browser sends the search query directly to the search server.</li>
    <li>The browser downloads the search results directly. (JSONP)</li>
    <li>The JavaScript on the browser renders the results on the screen.</li>
    <li>The user downloads the torrent directly from the source.</li>
</ol>

<p>So, in this way, all the service does is send some HTML and JavaScript to the user's phone.</p>

<p>The majority of the logic is <a href="http://jquerymobile.com/download/">stored on the jQuery CDN</a>.</p>

<p>It is the user's phone which then communicates with the search engine. The user's phone which receives the results. And the user's phone which renders them.</p>

<p>In this case, the server doesn't see any content - legal or otherwise - nor does it see any search requests.</p>

<h2 id="technical"><a href="https://shkspr.mobi/blog/2011/11/mobile-bit-torrent/#technical">Technical</a></h2>

<p>The code itself is fairly simple.</p>

<p>There are no reliable Bit Torrent search APIs which respond via JSONP.  However, <a href="https://web.archive.org/web/20111103004550/http://pipes.yahoo.com/pipes/search?r=tag%3Atorrent">Yahoo Pipes provides several "recipes"</a> which query APIs and return correctly formatted data.</p>

<p>Here's the skeleton code:</p>

<pre lang="javascript">var pipeURL = "http://pipes.yahoo.com/pipes/pipe.run?u="+
    searchTerm+
    "%26rows=10"+
    "%26sort="+
    sortBy+
    "&amp;_render=json&amp;_callback=?";

//  Get the JSONP and parse it
$.getJSON(pipeURL,
function(data)
{
    // An Array of list items to be added to the ul
    var listItems = [];
    //  Loop through the results
    $.each(data.value.items[0].items.list, function(i,item)
    {
        //  Get all the properties of each result
        var enclosure_url = item.enclosure_url;
        var title = item.title.replace(/(&lt; ([^&gt;]+)&gt;)/ig,""); // Strip tags

        //  Create a set of <li></li> which can be added to the <ul></ul>
        listItems.push('<li>'+title+'</li>');
    });
});
</pre>

<p>To reiterate, all of this runs on the mobile phone.  There is nothing happening on my server.</p>

<p>Now, I'm not sure that this is a cast iron legal defence - hence <strong>I am not making the site public</strong> - but it moves the action squarely on to the user.</p>

<p>In this case, the phone contacts Yahoo, Yahoo then contacts a Torrent search engine, the phone does all the sending, receiving, rendering, and downloading.  The server doesn't even see the search request.</p>

<h2 id="what-does-it-look-like"><a href="https://shkspr.mobi/blog/2011/11/mobile-bit-torrent/#what-does-it-look-like">What Does It Look Like?</a></h2>

<p>The initial page.
<img src="https://shkspr.mobi/blog/wp-content/uploads/2011/11/xmts-start.png" alt="" title="xmts start" width="320" height="285" class="aligncenter size-full wp-image-4656"></p>

<p>Searching
<img src="https://shkspr.mobi/blog/wp-content/uploads/2011/11/xmts-search.png" alt="" title="xmts search" width="320" height="284" class="aligncenter size-full wp-image-4657"></p>

<p>The results.
<img src="https://shkspr.mobi/blog/wp-content/uploads/2011/11/xmts-results.png" alt="" title="xmts results" width="320" height="497" class="aligncenter size-full wp-image-4658"></p>

<p>The user is then free to download the torrent.  Of course, the only torrent client I know for mobile phones is <a href="https://web.archive.org/web/20111118030451/http://amorg.aut.bme.hu/projects/symtorrent">SymTorrent</a> - and that only runs on older Symbian phones.  So this project is of no practical purpose.</p>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=4579&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2011/11/mobile-bit-torrent/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
