Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Use any song snippet as a cell phone ringtone' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use any song snippet as a cell phone ringtone
Authored by: on Jan 24, '06 06:20:50AM
For better quality, you can download the iTunes snippets directly, but it takes some command line know-how. basicallly, run tcpflow from the command line right before you preview a song in itunes. then stop the dump as soon as you start playing the song. Scroll to the top and figure out the url where the song lives.

$ sudo tcpflow -i en1 -c
tcpflow[683]: listening on en1 GET /Music/y2004/m08/d05/h17/s05.negqmhqy.p.m4p HTTP/1.1
Accept: */*
Cache-Control: no-cache
User-Agent: iTunes/6.0.2 (Macintosh; N; PPC)
Connection: close
From that, I figured out the song snippet lives at this url:

Track info, btw: Truckdrivin Neighbors Downstairs (Yellow Sweat) 2:55 Beck Mellow Gold $0.99

I'm sure it could be done with tcpdump also, but I've gotten in the habit of using tcpflow for some reason...

Writing a script to automate this would be cool. Probably beyond my abilities. Something like running the tcpdump command, pipe to grep, and somehow filter the output with regular expressions, construct the url and save the m4p file to your desktop with curl.

[ Reply to This | # ]
Use any song snippet as a cell phone ringtone
Authored by: Nathaniel Cross on Jan 24, '06 10:39:32AM

Here's a little command which I made a while ago:

sudo /usr/local/bin/tcpflow -c -i en0 port 80 | grep -oE '\<GET *.*\.m4p.*HTTP/1.1 *\>|Host: *.*'

Paste this into a terminal and press enter. Every time you then click on a sample in iTunes the terminal will display the URL. Press Ctrl-C to stop it.

Change the m4p in the script to mov to grab movies

[ Reply to This | # ]
Use any song snippet as a cell phone ringtone
Authored by: on Jan 31, '06 12:46:02AM
My perl hacker friend Dave Cash tackled this problem with me by writing a perl script. My only contribution is the hackish applescript contained therein. Here's the script:


use strict;
use LWP::UserAgent;
use Audio::M4P::Decrypt;

my $ua = new LWP::UserAgent;
my $deDRMS = new Audio::M4P::Decrypt;

my $host  = '';
my $path  = '';
my $file  = '';
my $agent = '';
my $info  = '';

#figure out how to know which network interface is currenlty active, en1 or en0 etc
open TCPFLOW, "sudo tcpflow -c -i en0 port 80 |";
#when bundling this as an application with perlwrapper, maybe I can just include a binary of tcpflow and have the path to tcpflow be something like /Applications/
while ( <TCPFLOW> ) {
	$path  ||= ( /GET *(.*?)[^\/]+\.m4p/ )[ 0 ];
	$file  ||= ( /GET *.*?([^\/]+\.m4p)/ )[ 0 ];
	$host  ||= ( /^Host: (.*?)[\n\r]*$/ )[ 0 ] if $path;
	$agent ||= ( /^User-Agent: (.*?)[\n\r]*$/ )[ 0 ];
	if ( $path && $host ) {
		if ( $agent =~ /^iTunes/ ) {

			# Use applescript and UI scripting to hackishly get the track name and title.  Returns something like this:
			# Song_Title	Track_Length	Artist	Album	Price
			# Jesus Doesn't Want Me for a Sunbeam (Live)	4:37	Nirvana	MTV Unplugged in New York: Nirvana	$0.99
			my $info = `osascript -e 'tell application "iTunes" to activate' -e 'tell application "System Events" to keystroke "c" using {command down}' -e 'return the clipboard'`;

			my ( $title, $length, $artist, $album, $price ) = split /\t/, $info;
			my $out_filename = $title ? "$ENV{ HOME }/Desktop/$artist - $album - $title.m4p" : $file;
			print qq!Getting $file to "$out_filename"...!;
			my $response = $ua->get( "http://$host$path$file" );
               		if ( $response->is_success ) {
                      		open OUT, qq!> /tmp/$file!;
                       		print OUT $response->content;
                       		close OUT;
				rename "/tmp/$file", $out_filename;
				print "done.$/";
                       		#$deDRMS->DeDRMS( "/Users/simon/Desktop/$file", "/Users/simon/Desktop/DONE_$file" );
                       		#unlink "/Users/simon/Desktop/$file";
			else {
				print "failed!$/";
       		$host = $path = $file = '';
close TCPLOW;
To use this script: save it somewhere as In Terminal, cd to the folder where you saved it. Type this command perl (You will probably need to install Audio::M4P::Decrypt from CPAN unless you already have it installed.) Once the script is running, go to iTunes and browse the music store. Each song you preview should be saved to the desktop. If you want to convert the protected AAC files to MP3, open hymn and process each file manually. It would be cool to make this script into a simple app using something like PerlWrapper. Then people who wanted to use it wouldn't have to know how to install CPAN or the command line. It could even include a binary of tcpflow so people wouldn't have to install that either.

[ Reply to This | # ]
Use any song snippet as a cell phone ringtone
Authored by: on Jan 31, '06 01:25:46AM
P.S. - the script seems to not work quite right the first couple of songs it tries to download. But keep trying and it will work eventually. I don't know how to debug it, but maybe an adventurous perl programmer can take a look. Also, if the UI applescript part that copies the text from the iTunes current selection fails (because you changed applications just as it was about to copy, for example), the file will be save to the directory where you saved the script instead of the desktop and it will have the original name that iTunes stores it as (something like s05.ypqjdnud.p.m4p). I saved this applescript:

tell application "Terminal"
	tell application "System Events"
		keystroke "n" using command down
		delay 1
	end tell
	set bounds of window 1 to {0, 22, 1280, 854}
	do script "cd ~/Library/Scripts/Applications/iTunes/" in window 1
	do script "perl" in window 1
end tell ~/Library/iTunes/Scripts/Save Music Store Previews to Desktop.scpt so I can easily start up the perl script from the iTunes script menu.

[ Reply to This | # ]
Use any song snippet as a cell phone ringtone
Authored by: johnzy on Jan 24, '06 06:46:59PM

I did this with my Nokia -- put a big memory card in it, used bluetooth to send (legal, that I had purchased) tunes to the phone. Piece of cake. The player is no itunes for sure, but it works. Then if I want to use a song for a ringtone, I pick about a 40-second slice using an editing app and select it as the ringtone. Everytime it rings, I get requests for people to help me do it with their phones. Rarely do they have the right gear. There's an opportunity here for businesses to do-right and make it easy for people to enjoy their FAIR USE rights. Will I ever pay for a ringtone? Of a tune I already own? Nope.

[ Reply to This | # ]