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


Groups > comp.lang.python > #41234

Re: Generating Filenames from Feeds

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'syntax': 0.03; 'append': 0.07; 'filename': 0.07; 'parsing': 0.07; 'extension,': 0.09; 'extension.': 0.09; 'parsed': 0.09; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'podcast': 0.16; 'reason.': 0.16; 'stripped': 0.16; 'whitespace.': 0.16; 'wrote:': 0.17; 'string,': 0.17; 'all,': 0.21; 'trying': 0.21; "haven't": 0.23; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'wondering': 0.26; 'errors.': 0.27; 'way?': 0.29; 'whitespace': 0.29; 'function': 0.30; 'error': 0.30; 'getting': 0.33; 'to:addr:python-list': 0.33; 'doing': 0.35; 'something': 0.35; 'there': 0.35; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'end': 0.40; 'skip:u 10': 0.60; 'first': 0.61; 'referred': 0.62; 'header:Reply-To:1': 0.68; 'reply-to:no real name:2**0': 0.72; 'reply-to:addr:python.org': 0.84
X-CM-Score 0.00
X-CNFS-Analysis v=2.0 cv=XeZXOvF5 c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=B68SgI_Jlq8A:10 a=PubsehdPSHsA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=pTPytuFYySIA:10 a=qlS4x6qrs7X5lL0RQ4YA:9 a=wPNLvfGTeEIA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117
X-AUTH mrabarnett:2500
Date Thu, 14 Mar 2013 16:07:43 +0000
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130307 Thunderbird/17.0.4
MIME-Version 1.0
To python-list@python.org
Subject Re: Generating Filenames from Feeds
References <a8aaf0a9-de8e-476f-9a34-e75694112802@googlegroups.com>
In-Reply-To <a8aaf0a9-de8e-476f-9a34-e75694112802@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To python-list@python.org
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3314.1363277253.2939.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1363277253 news.xs4all.nl 6850 [2001:888:2000:d::a6]:48712
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:41234

Show key headers only | View raw


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')

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

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

csiph-web