Created
August 23, 2012 08:07
-
-
Save theand/3434107 to your computer and use it in GitHub Desktop.
foxtube 앱으로 아이폰에 받아놓은 동영상을 iFunbox로 추출한 다음, 알아보기 힘든 *.mp4의 파일 이름을 *.info의 xml 문서에서 유투브 제목을 찾아내서 바꿔줌.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import os.path | |
import glob | |
os.chdir('c:\\temp\\swing\\') | |
for f in glob.glob('*.info'): | |
baseFile = os.path.basename(f) | |
srcName = os.path.splitext(baseFile)[0] | |
soup = BeautifulSoup(open(baseFile)) | |
targetName = soup.dict.find_all('string')[0].string | |
targetName = targetName.replace(':', ' - ') | |
targetName = targetName.replace('"', '') | |
targetName = targetName.replace('/', '-') | |
if not os.path.exists( srcName + '.mp4' ): | |
print "ERR: %s doesn't exists." % srcName | |
continue | |
#else: | |
#print "src : " + srcName + '.mp4' | |
if os.path.exists( targetName + '.mp4'): | |
print "ERR: %s already exists." % targetName | |
continue | |
#else: | |
#print "target : " + targetName + '.mp4' | |
try: | |
os.rename( srcName + u".mp4", targetName + u".mp4" ) | |
print "rename success" | |
except OSError: | |
print "ERR: srcName - " + srcName + " / targetName - " + targetName | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment