Skip to content
This repository has been archived by the owner on Mar 6, 2019. It is now read-only.

Commit

Permalink
Final commits for initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Harris committed Apr 1, 2010
1 parent 294a9b3 commit 59ca91c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
12 changes: 11 additions & 1 deletion README.rdoc
Expand Up @@ -57,6 +57,15 @@ is hope though! Heavy users of twitter may apply for an elevated rate limit of
shared via tweetftp, and the journey is more important than reaching the destination,
isn't it?

Search also has its limitation. Currently the Twitter search API returns no
more than 30 pages of 50 results, meaning that it currently constrains
uploaded files to a theoretical maximum of 1498 tweets of 77 Base-64 bits,
meaning a maximum file size of 901K if you wanted to retrieve all of the
fragments in a single go. That said, there are now multiple competing twitter
search engines, and the tweetftp should support a streaming mode for download
where fragments can be retrieved before the entire file is uploaded (not currently
supported in this code).

Since it would take only 60,000 or so tweets to transmit an MP3, there would
exist the natural temptation to use this mechanism for illegal file sharing.
This problem is best addressable through legal and social solutions however,
Expand All @@ -66,8 +75,9 @@ NEVER use tweetftp to illegally share copyrighted material.
== Roadmap

* Actual tests
* "Streaming" file downloads
* Checksum verifications of downloads
* TworrentTracker for tracking public file uploads to twitter
* Create a new standard named BitTworrent that allows files to be spread across multiple accounts.
* Get purchased by Google, Facebook, or a desperate media company.

== Copyright
Expand Down
19 changes: 16 additions & 3 deletions lib/tweetftp.rb
Expand Up @@ -69,9 +69,19 @@ def download(hash, sender, options={})

sorted_fragments = fragments.reject {|f| f =~ /^==/}.sort_by {|a| a.to_i }

puts sorted_fragments.inspect
#puts fragments.inspect

header = fragments.detect {|f| f =~ /^==BEGIN/}

raise "No header found!" if header.nil?

if header =~ /^==BEGIN ([^\s]+) (\d+) /
filename = $1
mode = $2
else
raise "Unable to parse the header"
end

mode = 644 # FIXME
tf.write "begin-base64 #{mode} tweetftp.tmp\n"

sorted_fragments.each do |f|
Expand All @@ -82,8 +92,11 @@ def download(hash, sender, options={})

tf.write "====\n"
tf.close

final_path = "#{options[:save_to].gsub(/\/$/, '')}/#{filename}"

system("uudecode -o /tweetftp.dat #{tf.path}")
system("uudecode -o #{final_path} #{tf.path}")
final_path
end

private
Expand Down

0 comments on commit 59ca91c

Please sign in to comment.