🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #203691

Re: [Dialog] .DAT to .mbox conversion?

#203691
From: Oliver Cromm
Date: Mon, 13 Aug 2007 04:15
87 lines
4438 bytes
On Sat, 11 Aug 2007 05:38:15 +0200, Bernd Rose wrote:

> On Thu, 9 Aug 2007 01:42:39 -0400, Oliver Cromm wrote:
> 
>>>> I didn't express myself clearly? I don't see the bribe going up.
> [...] 
>>> $35
> [...] 
>> It was basically a joke ... 
> 
> I had a good laugh watching this exchange during the last days. Since
> Charles posted his offer I wondered how you meddle out of this. ;-)

It was a little awkward, but giving money to MSF is a good thing. If I
continue feeling bad, I'll give the same amount :-)
 
>> FROMLINE = "From abc@xyz.invalid Mon Jan 01 00:00:00 1970\r\n"
> 
> You could extract the envelope-From from the Return-Path: header. 
> It is always the first line for mails and not available for Usenet
> postings. So you could also filter out the Usenet postings during 
> the parsing process, this way.

Whether there or in From, I would do that (only) in a more systematic
version.

I can't really test Mail so well because my own Dialog doesn't contain
mail right now (except for converted Mailing Lists, which differ from
ordinary mail, e.g. wrt the Return-Path).

> From msgXXXXX@export.from.40tude.invalid [24 chars current date 'asctime']
> 
> you can archive them and can easily identify the content, later.
> (The XXXXX would be a counter, of course.)

Interesting suggestion. Yes, I like that. 

>>     line.sub!(/^From /, ">From ")
> 
> You need to adjust this one. You not only need to "escape" lines starting
> with "From", but also with ">From", ">>From", and so on.

Thanks, this is an important correction.

Below the script with Bernd's suggestions incorporated. Charles, if you
have your filters still ready, consider doing the conversion again. 



#!/usr/bin/env ruby
# dattombx.rb
# Author: Oliver Cromm, 2007 with input from Bernd Rose
# creates a mbx file from each msg*.dat in Dialog's data direectory
# Usage: place into data dir and run - that's it!
# Backup your files first, no guarantees.

TIMESTRING = Time::now.asctime
EMPTYLINE = "\r\n"

def fromline(counter)
  return "From msg#{counter}@export.from.40tude.invalid 
end

counter = "00001"
Dir['msg*.dat'].each do |inp|
  fname = File.basename(inp, ".dat")+".mbx"
  out = File.open(fname, "wb")
  firstline = true
  out.print fromline(counter)
  File.open(inp).each do |line|
    line.chomp!
    line.gsub!(/^..../,'') if firstline
    firstline = false
    if line.sub!(/^\x7f/,'')
      out.print EMPTYLINE
      counter.succ!
      out.print fromline(counter)
    end
    line.sub!(/^(\>*From )/, ">\\1")
    out.print line, "\r\n"
  end
  out.print EMPTYLINE
  out.close
end 

-- 
Oliver C.
Technical Details
Message-ID: <1ldna5hf9sq6a.dlg@ocromm.my-fqdn.de>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!204.153.245.136.MISMATCH!aqua.octanews.net!news-out.octanews.net!indigo.octanews.net!auth.brown.octanews.com.POSTED!not-for-mail
References: <16n9t1ynvi8j2.dlg@ncdm.com> <nxsahp9pj00b$.dlg@sqwertz.com> <1wk9pc4x2ck6z$.dlg@ocromm.my-fqdn.de> <1ty9e76kkz658.dlg@ncdm.com> <nydjhcd39a0y$.dlg@ocromm.my-fqdn.de> <1vvi7q5d0q4rf.dlg@ncdm.com> <1a3wznzipiq2h$.dlg@ocromm.my-fqdn.de> <9si85jancxkk.dlg@ocromm.my-fqdn.de> <zk0obxz7cif8.dlg@ncdm.com> <14w8exlprcgmx$.dlg@ocromm.my-fqdn.de> <4ztwohnytd2r$.dlg@b.rose.tmpbox.news.arcor.de>

Show Full Headers
Complete Article Headers
Message-ID: <1ldna5hf9sq6a.dlg@ocromm.my-fqdn.de>
Subject: Re: [Dialog] .DAT to .mbox conversion?
Date: Mon, 13 Aug 2007 00:15:55 -0400
From: Oliver Cromm <lispamateur@yahoo.de>
References: <16n9t1ynvi8j2.dlg@ncdm.com> <nxsahp9pj00b$.dlg@sqwertz.com> <1wk9pc4x2ck6z$.dlg@ocromm.my-fqdn.de> <1ty9e76kkz658.dlg@ncdm.com> <nydjhcd39a0y$.dlg@ocromm.my-fqdn.de> <1vvi7q5d0q4rf.dlg@ncdm.com> <1a3wznzipiq2h$.dlg@ocromm.my-fqdn.de> <9si85jancxkk.dlg@ocromm.my-fqdn.de> <zk0obxz7cif8.dlg@ncdm.com> <14w8exlprcgmx$.dlg@ocromm.my-fqdn.de> <4ztwohnytd2r$.dlg@b.rose.tmpbox.news.arcor.de>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!204.153.245.136.MISMATCH!aqua.octanews.net!news-out.octanews.net!indigo.octanews.net!auth.brown.octanews.com.POSTED!not-for-mail
Newsgroups: news.software.readers
User-Agent: 40tude_Dialog/2.0.10.1
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Organization: Seminar fuer kritische Bananenwissenschaft
X-Face: .f:ZE>c\~9oJ+1nK#>ntSHOQS~4x"Qx2m(<D<@p$G"tzb1lgWLUGY.zApKa@VL_?d$r(8=?VjrD9=uY:x!+H=hvj58Uw7)Y9<:KMYD.+^~#qMpeg2rvt`{#2a~7YoyFaFaBEdo4.TJzBqgtCZZ:mku4J|hey}DE}_"z(rl0N)\Pxh*0$"3B2mr\01&YPY7WJ:2kSe'I#PqiTxs1s49!S#W85'\zMXy*wRgD,,k.=4:3M{(P"i6S;
 \az~ut3z`; ?*Y;
 &]11<(EPF-SN`|3PhyL%~AuZpoFjjE_oM1`znHPq_?uib2WXwE+q@m),cLq~B$r^5uO]u6?CEecn=%xsDXNVa(1DX.)O(
Lines: 87
NNTP-Posting-Date: 12 Aug 2007 23:16:20 CDT
X-Complaints-To: abuse@octanews.net