Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Syntactic Confectionary Delight
 
PerlMonks

Ed2K Link Maker

by #include (Curate)
 | Log in | Create a new user | The Monastery Gates | Super Search | 
 | Seekers of Perl Wisdom | Meditations | PerlMonks Discussion | 
 | Obfuscation | Reviews | Cool Uses For Perl | Perl News | Q&A | Tutorials | 
 | Poetry | Recent Threads | Newest Nodes | Donate | What's New | 

on Jun 03, 2003 at 03:56 UTC ( #262558=sourcecode: print w/ replies, xml ) Need Help??

Category: Miscellaneous
Author/Contact Info #include (include@riotmod.com)
http://www.linux.riotmod.com
Description: A small script that makes Ed2K links for use with the eDonkey P2P network. Just pass the script a filename as an argument, and the Ed2K link is printed to STDOUT. Uses Digest::MD5.

MASSIVE UPDATE: I pretty much rewrote the script from scratch and added a bunch of stuff: the ability to be used as both a commandline tool AND a GUI tool, the ability to hash multiple files, and some minor bugfixes. If you want to use the GUI, you must have Tk installed.
#!/usr/bin/perl
#
# ed2k_hash.pl
#
# Revision: 0.4
# Author: #include
# License: GPL
#
# Creates a "hash" link for use with the
# eDonkey2000 network, and prints it to
# STDOUT.  Works as both a commandline tool
# and as a GUI tool.  If the script is passed
# a list of filenames as arguments, it will
# print a link for each file to STDOUT.
# If the script is run with NO arguments,
# it starts in GUI mode.  A Tk dialog will
# pop up and ask for a filename.  The file's
# Ed2K link is printed to STDOUT.
#
# Usage:
#
# COMMANDLINE MODE
# $ perl ed2k_hash.pl myfile.zip other_file.zip thisfile.zip > finishe
+d_hash.txt
#
# GUI MODE
# $ perl ed2k_hash.pl
#
use Digest::MD5;
use strict;
my $text;

if ($#ARGV >= 0 )
{
  foreach my $fname (@ARGV)
  {
    print make_ed2k_link($fname);
  }
} else {
  # Start up the GUI
  use Tk;
  my $mw = MainWindow->new();
  $mw->title("ed2k_hash.pl");
  $mw->Label(-text=>"Please enter a filename to hash:")->pack(-fill=>'
+x');
  $mw->Entry(-width => 25, -textvariable, \$text)->pack(-anchor => 'nw
+',-fill=>'x');
  $mw->Button(-text => "OK",
    -command => \&do_hash )
    ->pack(-side => 'top',
    -anchor => 'nw',-fill=>'x');
  $mw->Button(-text => "Cancel",
    -command => sub { exit })
    ->pack(-side => 'top',
    -anchor => 'nw',-fill=>'x');

  MainLoop;
}

sub do_hash
{
    print make_ed2k_link($text);
    exit;
}

sub make_ed2k_link
{
  my($fname)=@_;
  my $ctx = Digest::MD5->new;
  open(TFILE,"<$fname") or die "Can't open target file ($fname).";
  $ctx->addfile(*TFILE);
  close TFILE;
  my $fhash = $ctx->hexdigest;
  my $fsize = -s $fname;
  return "ed2k://|file|$fname|$fsize|$fhash|\n";
}

Comment on Ed2K Link Maker
Download Code
Re: Ed2K Link Maker
by Anonymous Monk on Dec 31, 2008 at 01:20 UTC

Back to Code Catacombs

Login:
Password
remember me
What's my password?
Create A New User

Node Status?
node history
Node Type: sourcecode [id://262558]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (25)
Fletch
ww
FunkyMonk
jmcnamara
toolic
holli
Gavin
atcroft
CardinalNumber
jethro
kennethk
thezip
Eyck
tsee
LanX
pemungkah
5mi11er
cormanaz
gmargo
roho
ssandv
je44ery
molecules
MikeDexter
AriSoft
As of 2010-02-09 22:39 GMT
Sections?
The Monastery Gates
Seekers of Perl Wisdom
Meditations
PerlMonks Discussion
Categorized Q&A
Tutorials
Obfuscated Code
Perl Poetry
Cool Uses for Perl
Perl News
Information?
PerlMonks FAQ
Guide to the Monastery
What's New at PerlMonks
Voting/Experience System
Tutorials
Reviews
Library
Perl FAQs
Other Info Sources
Find Nodes?
Nodes You Wrote
Super Search
List Nodes By Users
Newest Nodes
Recently Active Threads
Selected Best Nodes
Best Nodes
Worst Nodes
Saints in our Book
Leftovers?
The St. Larry Wall Shrine
Offering Plate
Awards
Craft
Snippets Section
Code Catacombs
Quests
Editor Requests
Buy PerlMonks Gear
PerlMonks Merchandise
Planet Perl
Perlsphere
Use Perl
Perl.com
Perl 5 Wiki
Perl Jobs
Perl Mongers
Perl Directory
Perl documentation
CPAN
Random Node
Voting Booth?

What level of existential comfort do you require?

Palace
Executive suite at the best hotel
Regular hotel in a decent part of town
Motel
Boarding house
Sleeping Bag on Couch in Basement
Any port in a storm
Camping under the freeway overpass
Jail
Other

Results (283 votes), past polls