简体   繁体   English

下载时解压缩存档

[英]unrar archive while downloading it

I've got a program that downloads part01, then part02 etc of a rar file split across the internet.我有一个程序下载part01,然后part02等rar文件在互联网上拆分。 My program downloads part01 first, then part02 and so on.我的程序先下载part01,然后下载part02,以此类推。 After some tests, I found out that using, on example, UnRAR2 for python I can extract the first part of the file (an.avi file) contained in the archive and I'm able to play it for the first minutes.经过一些测试,我发现例如使用 UnRAR2 for python 我可以提取存档中包含的文件的第一部分(一个.avi 文件),并且可以在最初几分钟内播放它。 When I add another file it extracts a bit more and so on.当我添加另一个文件时,它会提取更多内容,依此类推。 What I wonder is: is it possible to make it extract single files WHILE downloading them?我想知道的是:是否可以在下载单个文件时提取它们? I'd need it to start extracting part01 without having to wait for it to finish downloading... is that possible?我需要它来开始提取 part01 而不必等待它完成下载......这可能吗?

Thank you very much!非常感谢!

Matteo马泰奥

You are talking about an.avi file inside the rar archives.您正在谈论 rar 档案中的 .avi 文件。 Are you sure the archives are actually compressed?您确定档案实际上是压缩的吗? Video files released by the warez scene do not use compression: warez 场景发布的视频文件不使用压缩:

Ripped movies are still packaged due to the large filesize, but compression is disallowed and the RAR format is used only as a container.由于文件很大,翻录的电影仍被打包,但不允许压缩,RAR 格式仅用作容器。 Because of this, modern playback software can easily play a release directly from the packaged files, and even stream it as the release is downloaded (if the network is fast enough).正因为如此,现代播放软件可以很容易地直接从打包的文件中播放一个版本,甚至 stream 它作为版本下载(如果网络足够快的话)。

(I'm thinking VLC, BSPlayer, KMPlayer, Dziobas Rar Player, rarfilesource, rarfs,...) You can check for the compression as follows: (我在想 VLC、BSPlayer、KMPlayer、Dziobas Rar Player、rarfilesource、rarfs、...)您可以按如下方式检查压缩:

  • Open the first.rar archive in WinRAR.在 WinRAR 中打开 first.rar 压缩包。 (name.part01.rar or name.rar for old style volumes names ) (name.part01.rar 或 name.rar 用于旧式卷名
  • Click the info button.单击信息按钮。

If Version to extract indicates 2.0, then the archive uses no compression.如果要提取的版本指示 2.0,则存档不使用压缩。 (unless you have decade old rars) You can see Total size and Packed size will be equal. (除非你有十年前的 rars)你可以看到总大小打包大小是相等的。

is it possible to make it extract single files WHILE downloading them?是否可以在下载单个文件时提取它们?

Yes.是的。 When no compression is used, you can write your own program to extract the files.当不使用压缩时,您可以编写自己的程序来提取文件。 (I know of someone who wrote a script to directly download the movie from external rar files; but it's not public and I don't have it.) Because you mentioned Python I suggest you take a look at rarfile 2.2 by Marko Kreen like the author of pyarrfs did. (我知道有人写了一个脚本来直接从外部 rar 文件下载电影;但它不是公开的,我没有它。)因为你提到了 Python 我建议你看看 Marko Kreen 的rarfile 2.2就像pyarrfs的作者做到了。 The archive is just the file chopped up with headers (rar blocks) added.存档只是添加了标题(rar 块)的文件。 It will be a copy operation that you need to pause until the next archive is downloaded.这将是您需要暂停的复制操作,直到下载下一个存档。

I strongly believe it is also possible for compressed files.我坚信压缩文件也是可能的。 Your approach here will be different because you must use unrar to extract the compressed files.您在这里的方法会有所不同,因为您必须使用unrar来提取压缩文件。 I have to add that there is also a free RARv3 implementation to extract rars implemented in The Unarchiver.我必须补充一点,还有一个免费的 RARv3 实现来提取在 Unarchiver 中实现的 rars。

I think this parameter for (un)rar will make it possible:我认为(un)rar的这个参数将使它成为可能:

 -vp Pause before each volume By default RAR asks for confirmation before creating or unpacking next volume only for removable disks. This switch forces RAR to ask such confirmation always. It can be useful if disk space is limited and you wish to copy each volume to another media immediately after creation.

It will give you the possibility to pause the extraction until the next archive is downloaded.它使您可以暂停提取,直到下载下一个存档。

I believe that this won't work if the rar was created with the 'solid' option enabled.我相信如果 rar 是在启用 'solid' 选项的情况下创建的,这将不起作用。

When the solid option is used for rars, all packed files are treated as one big file stream .当 rars 使用 solid 选项时,所有打包文件都被视为一个大文件 stream This should not cause any problems if you always start from the first file even if it doesn't contain the file you want to extract.如果您总是从第一个文件开始,即使它不包含您要提取的文件,这应该不会导致任何问题。 I also think it will work with passworded archives.我也认为它适用于密码档案。

I highly doubt it.我对此表示高度怀疑。 By nature of compression (from my understanding), every bit is needed to uncompress it.根据压缩的性质(根据我的理解),解压缩它需要每一位。 It seems that the source of where you are downloading from has intentionally broken the avi into pieces before compression, but by the time you apply compression, whatever you compressed is now one atomic unit.似乎您下载的来源在压缩之前故意将 avi 分解成碎片,但是当您应用压缩时,您压缩的任何内容现在都是一个原子单位。 So they kindly broke the whole avi into Parts, but each Part is still an atomic nit.所以他们好心地将整个 avi 分解成 Parts,但每个 Part 仍然是一个原子 nit。

But I'm not an expert in compression.但我不是压缩专家。

The only test I can currently think of is something like: curl http://example.com/Part01 | unrar我目前能想到的唯一测试是: curl http://example.com/Part01 | unrar curl http://example.com/Part01 | unrar . curl http://example.com/Part01 | unrar

I don't know if this was asked with a specific language in mind, but it is possible to stream a compressed RAR directly from the internet and have it decompressed on the fly.我不知道这是否是在考虑特定语言的情况下提出的,但是可以直接从 Internet 获取 stream 压缩 RAR 并即时解压缩。 I can do this with my C# library http://sharpcompress.codeplex.com/我可以用我的 C# 库http://sharpcompress.codeplex.com/做到这一点

The RAR format is actually kind of nice. RAR 格式实际上有点好。 It has headers preceding each entry and the compressed data itself does not require random access on the stream of bytes.它在每个条目之前都有标头,压缩数据本身不需要随机访问 stream 字节。

Do it multi-part files, you'd have to fully extract part 1 first, then continue writing when part 2 is available.做多部分文件,您必须先完全提取第 1 部分,然后在第 2 部分可用时继续编写。

All of this is possible with my RarReader API.这一切都可以通过我的 RarReader API 实现。 Solid archive are also streamable (in fact, they're only streamable. You can't randomly access files in a solid archive. You pretty much have to extract them all at once.)实体存档也是可流式传输的(实际上,它们只是可流式传输的。您不能随机访问实体存档中的文件。您几乎必须一次提取所有文件。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM