Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- #v3 tags: http://pastebin.com/VJEBGauL
- #v2 tags: http://pastebin.com/z9mz71yd
- #----------------------------------------------------------------------
- def parseID3v3():
- """saves the tags as a dict"""
- tags = {}
- #ID3 tags http://stackoverflow.com/questions/11319123/grab-two-parts-of-a-single-short-string
- with open(r'..\Actual\ID3v3 tags.txt')as f:
- for line in f.readlines():
- full_match = re.search(r'^\S+\s+(\S+)\s+\[#\S+ (.*?)\]', line)
- dict_key = full_match.group(1) # 'AENC'
- id3v3_tag = full_match.group(2) # 'Audio encryption'
- print dict_key, ':', id3v3_tag
- tags[dict_key] = id3v3_tag
- return tags
- #----------------------------------------------------------------------
- def parseID3v2():
- """saves the tags as a dict"""
- tags = {}
- #ID3 tags http://stackoverflow.com/questions/11319123/grab-two-parts-of-a-single-short-string
- with open(r'..\Actual\ID3v2 tags.txt')as f:
- for line in f.readlines():
- try:
- line = line.strip()
- full_match = re.search(r'^\S+\s+(\S+)+\s+(\S+)', line)
- dict_key = full_match.group(1) # 'AENC'
- id3v2_tag = full_match.group(2) # 'Audio encryption'
- print dict_key, ':', id3v2_tag
- tags[dict_key] = id3v2_tag
- except AttributeError as e:
- print e, 'with line: >>', line, '<<'
- return tags
- print parseID3v3().keys()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement