FLV and MP4 From Opera Cache
Y901x 0.1.6 公開しました。
MIME Types でリストアップに変更したから拡張子無しでも再生可能に!
YouTube 等のキャッシュファイルのリネーム以外に使い道が無いのは気にしない。
ついでに Opera キャッシュから flv や H.264 を取り出す方法も都合よいように書き換え。
Nautilus をスクリプトで拡張
の覚書ページにも書いたけどブログにも書いておきます。
2009.06.25 URI 変換方法が間違っていたので書き換え
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import os
import shutil
import urllib
import gnomevfs
#src_path = os.path.expanduser("~/.opera/cache4") # opera 9
src_path = os.path.expanduser("~/.opera/cache") # opera 10
# 以下は自分の作業ディレクトリに変更してね
dst_path = os.path.expanduser("~/_temp")
ls = os.listdir(src_path)
for f in ls:
src = os.path.join(src_path, f)
# URI に変換
uri = "file:///" + urllib.quote(src)
# MIME Type を得る
mime = gnomevfs.get_mime_type(uri)
# FLV か H.264 をコピー
if mime == "video/x-flv":
# 拡張子を付加
f += ".flv"
dst = os.path.join(dst_path, f)
shutil.copyfile(src, dst)
elif mime == "video/mp4":
# 拡張子を付加
f += ".mp4"
dst = os.path.join(dst_path, f)
shutil.copyfile(src, dst)
いやぁただ MIME Type を得る方法を知っただけで色々使えますね。
Enjoy!