Unix Technical Forum

Stupid question regarding btdownloadxterm.sh

This is a discussion on Stupid question regarding btdownloadxterm.sh within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> Hey ho. I'd like to edit the file btdownloadxterm.sh so that it first copies the torrent file to ~/BitTorrent ...


Go Back   Unix Technical Forum > Unix Operating Systems > Slackware Linux Support

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-19-2008, 11:57 AM
Jesse F. Hughes
 
Posts: n/a
Default Stupid question regarding btdownloadxterm.sh

Hey ho.

I'd like to edit the file btdownloadxterm.sh so that it first copies
the torrent file to ~/BitTorrent and then calls xterm as it is. This
way, if I don't finish getting the file, I can later start up from the
command line rather than find the torrent via the browser a second
time.

This should be trivial, but I just don't know how to send
btdownloadxterm.sh the file name for the torrent. If I had that, then
I could just do "cp $1 $filename". Perhaps btdownloadxterm.sh needs
to take a second argument, but then what? Is there some percent sign
code that gives the preferred name of the file?

--
Jesse F. Hughes
"It's easy folks. Just talk about my approach to your favorite
mathematician. If they can't be interested in it, they've
demonstrated a lack of mathematical skill." -- James Harris
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-19-2008, 11:57 AM
Georg Neis
 
Posts: n/a
Default Re: Stupid question regarding btdownloadxterm.sh

* Jesse F. Hughes <jesse@phiwumbda.org> wrote:
> I'd like to edit the file btdownloadxterm.sh so that it first copies
> the torrent file to ~/BitTorrent and then calls xterm as it is. This
> way, if I don't finish getting the file, I can later start up from the
> command line rather than find the torrent via the browser a second
> time.
>
> This should be trivial, but I just don't know how to send
> btdownloadxterm.sh the file name for the torrent. If I had that, then
> I could just do "cp $1 $filename".


Actually, $1 _is_ the filename of the torrent file. Just add the
following line (above the last line, of course):

cp "$1" "$HOME"/BitTorrent

Georg
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-19-2008, 11:58 AM
Jesse F. Hughes
 
Posts: n/a
Default Re: Stupid question regarding btdownloadxterm.sh

Georg Neis <georg@fli4l.de> writes:

> * Jesse F. Hughes <jesse@phiwumbda.org> wrote:
>> I'd like to edit the file btdownloadxterm.sh so that it first copies
>> the torrent file to ~/BitTorrent and then calls xterm as it is. This
>> way, if I don't finish getting the file, I can later start up from the
>> command line rather than find the torrent via the browser a second
>> time.
>>
>> This should be trivial, but I just don't know how to send
>> btdownloadxterm.sh the file name for the torrent. If I had that, then
>> I could just do "cp $1 $filename".

>
> Actually, $1 _is_ the filename of the torrent file. Just add the
> following line (above the last line, of course):
>
> cp "$1" "$HOME"/BitTorrent


But it's the filename of the torrent file as it's saved now, which is
typically in a temporary location. That's not a very good filename
(even if I throw away the path and keep just the basename).

At the TV Torrents site, the torrent is served by a cgi-script. If I
choose to save the torrent, then Konqueror chooses a good name for
it. If I choose to call btdownloadxterm.sh, Konqueror chooses a
temporary file name for it and sends that file name to the script.

Konqueror must be getting the "good" name from *somewhere*, but I
can't guess where.

Thanks.
--
Jesse F. Hughes
"Of course, my ability to admit my mistakes and correct them is a
trait that many of you seem to never have properly appreciated."
-- JSH, discussing his 1463rd "proof" of Fermat's Last Theorem.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-19-2008, 11:58 AM
Georg Neis
 
Posts: n/a
Default Re: Stupid question regarding btdownloadxterm.sh

* Jesse F. Hughes <jesse@phiwumbda.org> wrote:
> Georg Neis <georg@fli4l.de> writes:
> > * Jesse F. Hughes <jesse@phiwumbda.org> wrote:
> >> I'd like to edit the file btdownloadxterm.sh so that it first copies
> >> the torrent file to ~/BitTorrent and then calls xterm as it is. This
> >> way, if I don't finish getting the file, I can later start up from the
> >> command line rather than find the torrent via the browser a second
> >> time.
> >>
> >> This should be trivial, but I just don't know how to send
> >> btdownloadxterm.sh the file name for the torrent. If I had that, then
> >> I could just do "cp $1 $filename".

> >
> > Actually, $1 _is_ the filename of the torrent file. Just add the
> > following line (above the last line, of course):
> >
> > cp "$1" "$HOME"/BitTorrent

>
> But it's the filename of the torrent file as it's saved now, which is
> typically in a temporary location. That's not a very good filename
> (even if I throw away the path and keep just the basename).
>
> At the TV Torrents site, the torrent is served by a cgi-script. If I
> choose to save the torrent, then Konqueror chooses a good name for
> it. If I choose to call btdownloadxterm.sh, Konqueror chooses a
> temporary file name for it and sends that file name to the script.


Okay, I understand the problem. I tested with Mozilla Firefox and
it took the proper filename. You could use btshowmetainfo.py to
extract a (hopefully) useful name from the torrent file:

$ btshowmetainfo.py ~/BitTorrent/slackware-9.1-source-d3.torrent
btshowmetainfo 20021207 - decode BitTorrent metainfo files

metainfo file.: slackware-9.1-source-d3.torrent
info hash.....: f67fdc4888fbdfff80c76d3ffd5d212f512efd74
directory name: slackware-9.1-iso
files.........:
slackware-9.1-source-d3.iso (689995776)
slackware-9.1-source-d3.iso.asc (189)
slackware-9.1-source-d3.iso.md5 (62)
archive size..: 689996027 (2632 * 262144 + 33019)
announce url..: http://transamrit.net:8082/announce

$ btshowmetainfo.py BitTorrent/slackware-9.1-source-d3.torrent \
| grep "^metainfo file.:" | sed 's/^.*: //'
slackware-9.1-source-d3.torrent

Add to btdownloadxterm.sh something like this:

name="`btshowmetainfo.py \"$1\" | grep '^metainfo file.:' | sed 's/^.*: //'`"
cp "$1" ~/BitTorrent/"$name" # you may want to check if there's
# already a file with this name here

Georg
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-19-2008, 11:58 AM
Georg Neis
 
Posts: n/a
Default Re: Stupid question regarding btdownloadxterm.sh

* Georg Neis <georg@fli4l.de> wrote:
> Okay, I understand the problem. I tested with Mozilla Firefox and
> it took the proper filename. You could use btshowmetainfo.py to
> extract a (hopefully) useful name from the torrent file:
>
> $ btshowmetainfo.py ~/BitTorrent/slackware-9.1-source-d3.torrent
> btshowmetainfo 20021207 - decode BitTorrent metainfo files
>
> metainfo file.: slackware-9.1-source-d3.torrent


Damn! That's always the name of the file we are looking at...

> info hash.....: f67fdc4888fbdfff80c76d3ffd5d212f512efd74
> directory name: slackware-9.1-iso
> files.........:
> slackware-9.1-source-d3.iso (689995776)
> slackware-9.1-source-d3.iso.asc (189)
> slackware-9.1-source-d3.iso.md5 (62)
> archive size..: 689996027 (2632 * 262144 + 33019)
> announce url..: http://transamrit.net:8082/announce


Hmm, you could extract the name from the "directory name" line but
not every torrent file has such a line, e.g.:

metainfo file.: sdfsdf.torrent
info hash.....: 323423842034982304234239487234247923293487
file name.....: dfjasdfjasdl.mpg
file size.....: 426475212 (406 * 1048576 + 753356)
announce url..: http://foo.bar

Maybe you give Firefox a try? ;-)
Georg
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-19-2008, 11:58 AM
Jesse F. Hughes
 
Posts: n/a
Default Re: Stupid question regarding btdownloadxterm.sh

Georg Neis <georg@fli4l.de> writes:

> * Georg Neis <georg@fli4l.de> wrote:
>> Okay, I understand the problem. I tested with Mozilla Firefox and
>> it took the proper filename. You could use btshowmetainfo.py to
>> extract a (hopefully) useful name from the torrent file:
>>
>> $ btshowmetainfo.py ~/BitTorrent/slackware-9.1-source-d3.torrent
>> btshowmetainfo 20021207 - decode BitTorrent metainfo files
>>
>> metainfo file.: slackware-9.1-source-d3.torrent

>
> Damn! That's always the name of the file we are looking at...
>
>> info hash.....: f67fdc4888fbdfff80c76d3ffd5d212f512efd74
>> directory name: slackware-9.1-iso
>> files.........:
>> slackware-9.1-source-d3.iso (689995776)
>> slackware-9.1-source-d3.iso.asc (189)
>> slackware-9.1-source-d3.iso.md5 (62)
>> archive size..: 689996027 (2632 * 262144 + 33019)
>> announce url..: http://transamrit.net:8082/announce

>
> Hmm, you could extract the name from the "directory name" line but
> not every torrent file has such a line, e.g.:
>
> metainfo file.: sdfsdf.torrent
> info hash.....: 323423842034982304234239487234247923293487
> file name.....: dfjasdfjasdl.mpg
> file size.....: 426475212 (406 * 1048576 + 753356)
> announce url..: http://foo.bar
>
> Maybe you give Firefox a try? ;-)


Well, thanks for the pointer to btshowmetainfo.py. I had overlooked
that tool. The files in which I'm interested probably have just one
file in them, so it would be reasonable to take the "file name" data
in that case.

I wonder if it's true that every torrent has either a directory name
or a file name. Hey! Yep. It looks like that's the case according
to <http://wiki.theory.org/index.php/BitTorrentSpecification>.

Thanks much. This will work just peachy.

--
"Come on people!!! The US just blew up a lot of people in Iraq, don't
you realize that a person with my exposure might just end up dead, by
mysterious circumstances?"
--James Harris, on the dangers of "proving" Fermat's last theorem
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:33 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com