Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41232 > unrolled thread

Generating Filenames from Feeds

Started byChuck <galois271@gmail.com>
First post2013-03-14 08:38 -0700
Last post2013-03-14 16:07 +0000
Articles 6 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  Generating Filenames from Feeds Chuck <galois271@gmail.com> - 2013-03-14 08:38 -0700
    Re: Generating Filenames from Feeds Joel Goldstick <joel.goldstick@gmail.com> - 2013-03-14 12:05 -0400
      Re: Generating Filenames from Feeds Chuck <galois271@gmail.com> - 2013-03-14 11:19 -0700
        Re: Generating Filenames from Feeds Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-14 22:58 +0000
      Re: Generating Filenames from Feeds Chuck <galois271@gmail.com> - 2013-03-14 11:19 -0700
    Re: Generating Filenames from Feeds MRAB <python@mrabarnett.plus.com> - 2013-03-14 16:07 +0000

#41232 — Generating Filenames from Feeds

FromChuck <galois271@gmail.com>
Date2013-03-14 08:38 -0700
SubjectGenerating Filenames from Feeds
Message-ID<a8aaf0a9-de8e-476f-9a34-e75694112802@googlegroups.com>
HI all,

I am trying to write a podcast catcher for fun, and I am trying to come up with a way to generate a destination filename to use in the function urlretrieve(url, destination).  I  would like the destination filename to end in a .mp3 extension.  

My first attempts were parsing out the <pubdate> and stripping the whitespace characters, and joining with os.path.join.  I haven't been able to make that work for some reason.  Whenever I put the .mp3 in the os.path.join I get syntax errors.  I am wondering if there is a better way?

I was doing something like os.path.join('C:\\Users\\Me\\Music\\Podcasts\\', pubdate.mp3), where pubdate has been parsed and stripped of whitespace.  I keep getting an error around the .mp3.

Any ideas?

Thanks!!
Chuck  

[toc] | [next] | [standalone]


#41233

FromJoel Goldstick <joel.goldstick@gmail.com>
Date2013-03-14 12:05 -0400
Message-ID<mailman.3313.1363277108.2939.python-list@python.org>
In reply to#41232

[Multipart message — attachments visible in raw view] — view raw

On Thu, Mar 14, 2013 at 11:38 AM, Chuck <galois271@gmail.com> wrote:

> HI all,
>
> I am trying to write a podcast catcher for fun, and I am trying to come up
> with a way to generate a destination filename to use in the function
> urlretrieve(url, destination).  I  would like the destination filename to
> end in a .mp3 extension.
>
> My first attempts were parsing out the <pubdate> and stripping the
> whitespace characters, and joining with os.path.join.  I haven't been able
> to make that work for some reason.


The reason is apparently a  syntax error.

Whenever I put the .mp3 in the os.path.join I get syntax errors.  I am
> wondering if there is a better way?
>

Yes, don't write code with syntax errors!

>
> I was doing something like
> os.path.join('C:\\Users\\Me\\Music\\Podcasts\\', pubdate.mp3), where
> pubdate has been parsed and stripped of whitespace.  I keep getting an
> error around the .mp3.
>
> Any ideas?
>

Seriously, if you don't post a minimal code example that shows the problem
and with a full traceback you are asking strangers to do magic tricks for
your pleasure.

>
> Thanks!!
> Chuck
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com

[toc] | [prev] | [next] | [standalone]


#41237

FromChuck <galois271@gmail.com>
Date2013-03-14 11:19 -0700
Message-ID<d7114660-bf09-4210-91d0-83a2d0c26c34@googlegroups.com>
In reply to#41233
> Seriously, if you don't post a minimal code example that shows the problem and with a full traceback you are asking strangers to do magic tricks for your pleasure. 

I'm asking more for a better way of generating destination filenames, not so much debugging questions.  I only put my attempts there to show people that I was actually trying something, and not just relying on people to do my thinking for me.

I'm trying to take a feed such as this 

http://www.theskepticsguide.org/feed/rss.aspx?feed=SGU

and parse some useful data out of it for a destination filename.  The solution should be general, and not just for this particular feed.

Thanks!














[toc] | [prev] | [next] | [standalone]


#41248

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-03-14 22:58 +0000
Message-ID<51425610$0$29965$c3e8da3$5496439d@news.astraweb.com>
In reply to#41237
On Thu, 14 Mar 2013 11:19:18 -0700, Chuck wrote:

>> Seriously, if you don't post a minimal code example that shows the
>> problem and with a full traceback you are asking strangers to do magic
>> tricks for your pleasure.
> 
> I'm asking more for a better way of generating destination filenames,
> not so much debugging questions.  I only put my attempts there to show
> people that I was actually trying something, and not just relying on
> people to do my thinking for me.
> 
> I'm trying to take a feed such as this
> 
> http://www.theskepticsguide.org/feed/rss.aspx?feed=SGU
> 
> and parse some useful data out of it for a destination filename.  The
> solution should be general, and not just for this particular feed.

There is no such general solution, because "some useful data" will depend 
on what you intend to do with it, what the feed is, and what *you* 
consider "useful".

Your earlier approach is probably fine, once you fix the syntax error.


-- 
Steven

[toc] | [prev] | [next] | [standalone]


#41238

FromChuck <galois271@gmail.com>
Date2013-03-14 11:19 -0700
Message-ID<mailman.3317.1363285167.2939.python-list@python.org>
In reply to#41233
> Seriously, if you don't post a minimal code example that shows the problem and with a full traceback you are asking strangers to do magic tricks for your pleasure. 

I'm asking more for a better way of generating destination filenames, not so much debugging questions.  I only put my attempts there to show people that I was actually trying something, and not just relying on people to do my thinking for me.

I'm trying to take a feed such as this 

http://www.theskepticsguide.org/feed/rss.aspx?feed=SGU

and parse some useful data out of it for a destination filename.  The solution should be general, and not just for this particular feed.

Thanks!














[toc] | [prev] | [next] | [standalone]


#41234

FromMRAB <python@mrabarnett.plus.com>
Date2013-03-14 16:07 +0000
Message-ID<mailman.3314.1363277253.2939.python-list@python.org>
In reply to#41232
On 14/03/2013 15:38, Chuck wrote:
> HI all,
>
> I am trying to write a podcast catcher for fun, and I am trying to
> come up with a way to generate a destination filename to use in the
> function urlretrieve(url, destination).  I  would like the
> destination filename to end in a .mp3 extension.
>
> My first attempts were parsing out the <pubdate> and stripping the
> whitespace characters, and joining with os.path.join.  I haven't been
> able to make that work for some reason.  Whenever I put the .mp3 in
> the os.path.join I get syntax errors.  I am wondering if there is a
> better way?
>
> I was doing something like
> os.path.join('C:\\Users\\Me\\Music\\Podcasts\\', pubdate.mp3), where
> pubdate has been parsed and stripped of whitespace.  I keep getting
> an error around the .mp3.
>
> Any ideas?
>
The filename referred to by pubdate is a string, and you want to append
an extension, also a string, to it. Therefore:

os.path.join('C:\\Users\\Me\\Music\\Podcasts\\', pubdate + '.mp3')

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web