📜 ⬆️ ⬇️

iPod and Python: sort albums in chronological order

Problem


Sometimes it seems to me that Apple is trying hard to simplify its products. On the one hand, it is wonderful, but on the other - it is very regrettable. After all, additional settings complicate our life in the first couple of weeks of using the product (until you get used to it, you will understand), but then they allow you to customize it for yourself and get the gadget (or program) of your dreams.

Album by Year If you are a happy owner of iPod, then you probably noticed that all the albums on it (on the player) are sorted strictly in alphabetical order. And nothing else. And you no settings and expert-mods. They said "in alphabetical order", it means in alphabetical order. What is remarkable - there is such a button in iTunes ( Album by Year ). But there I needed it the least.

Fortunately, this problem (as well as the problem of adding separately downloaded episodes to an existing iTunes podcast) has a solution. Not as simple as we would like, but very exciting.
')

Solve the forehead


A completely simple, but not too elegant solution comes in the first in the first couple of seconds. Just for all the albums we turn the contents of the tag % album% into % year% -% album% , and the problem is solved. And it is sorted as it should, and even the year can be viewed directly on iPod-e (without this kind of preparation, the year of release of the album on the player itself cannot be clarified).

Perhaps you are satisfied with this option, but it seemed to me unsatisfactory. One thing is a folder on the disk (I used to call them in the format% year% -% album%), and another thing is an elegant album with albumart on iPod-e. In addition, I am not interested in the specific year in which the album was released. I just want to know which albums belong to the early work of this or that group, and which were released just recently, to see how the group has changed over time, how its style has changed. This is what prompted me to study the problem in more detail and search for its solution.

iTunes


There are no perfect programs. iTunes is no exception. Nevertheless, it is a convenient and enjoyable application. At least that's how I began to think after several months of use, when I finally came to terms with this Apple simplicity. And when it turned out that there is something in iTunes that will help solve the problem to a certain extent, I finally got rid of my thoughts about searching for an iTunes replacement.

He said: "Let's go!"


Entry behind and finally we begin to act. Select all the tracks of an album and open the context menu. There we find a great item Get Info , which hides all the information about the selected tracks. We are currently interested in the Sorting tab:
Sorting tab

I did not specify the purpose of these fields in the documentation, but all my life experience suggests that if the Sort Album field is filled, then when sorting albums in iTunes (if not Album by Year is selected in the album column, but simply Album ) it is the key that will be the key (similarly to the other sort fields). And, most importantly, the same key will be used when sorting albums directly on the player itself. This is what we need. We enter in the specified field “2007 - Are You Listening” and rejoice at how everything went smoothly with us. Now we have exactly one album, which is sorted (with itself) in chronological order =)

And ahead - forever


The problem seemed to be solved. And in fact, everything is just beginning. After releasing the player to the n-th number of gigabytes, Apple should simply not expect that you can buy so much music from the Apple Store (and other sources probably did not take into account). Or maybe they did not expect that one day they would want to sort all the albums by date. The fact is that I simply cannot repeat this procedure with the remaining five hundred albums in my record library. As stated in a recent C # puzzle: “Never send a human to a machine machine job”.

And then Python appears on the scene.


That is what we use to process our library. All at once.

As it turned out, iTunes saves the value of the " Sort Album " field in the TSOA tag of the mp3 file (you can read about other iTunes tags here ). Knowing this, we can appropriately fill this tag in our files, and then add them to the iTunes library.

Python libraries for working with id3 tags turned out to be not much, but not a little. My choice fell on mutagen (other options can be found here ).

Mutagen allows you to work with the metadata of a sufficiently large number of audio formats (ASF, FLAC, M4A, Monkey's Audio, MP3, Musepack, Ogg FLAC, Ogg Speex, Ogg Theora, etc.) We are interested in id3 tags in mp3-files. The library provides two interfaces for manipulating them: ID3 and EasyID3 . I think the difference is not necessary to explain. At first I played with the first one, but then it turned out that the capabilities of the second one are quite enough.

Actually code


At once I will make a reservation that my Python-e programming experience tends to infinity, but so far is approximately zero. I tried to write everything so that it would not be a shame to show it to society, but I am not sure that it turned out quite well. Therefore, I would appreciate any meaningful comments expressed in a friendly way.

As for the algorithm, it is quite obvious: we run through the necessary files, extract the release year and the album name from the tags and fill in the TSOA tag accordingly . I came to the conclusion that the % artist% -% year% -% album %% format suits me the most. With this TSOA tag value, the albums will be sorted by artist, then by year, and then alphabetically (if all of a sudden one fine year your favorite band discarded more than one album). Python, they say, has a very friendly syntax, so even if you are not familiar with it, making small adjustments to your liking in the script below will not be a problem.

In the process of processing five thousand tracks, a lot can happen, so I added a little service output to observe how things are progressing, and a log for displaying errors about the lack of tags in the file. After all, adding to iTunes a file without an artist or album in tags is a bad thing, so it will be useful to find out which files we are not yet ready to migrate to iPod.

I was too lazy to c docstring, but I diluted the code with comments. I hope this will help orient those who are not very familiar with Python.

Code:
Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  1. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  2. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  3. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  4. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  5. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  6. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  7. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  8. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  9. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  10. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  11. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  12. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  13. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  14. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  15. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  16. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  17. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  18. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  19. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  20. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  21. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  22. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  23. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  24. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  25. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  26. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  27. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  28. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  29. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  30. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  31. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  32. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  33. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  34. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  35. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  36. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  37. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  38. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  39. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  40. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  41. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  42. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  43. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  44. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  45. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  46. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  47. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  48. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  49. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  50. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  51. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  52. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  53. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  54. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  55. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  56. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  57. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  58. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  59. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  60. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  61. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  62. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  63. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  64. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  65. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  66. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  67. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  68. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  69. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  70. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  71. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  72. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  73. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();
  74. Copy Source | Copy HTML #!usr/bin/env python # -*- coding: utf-8 -*- # Created by KL-7 import logging import sys from os import path from mutagen.easyid3 import EasyID3 from mutagen.id3 import ID3NoHeaderError # totalfiles = 0 # def error (err): # - logging .basicConfig(filename= "error.log" , level= logging .ERROR) logging . error (err) # tagname audio def gettag (audio, tagname): taglist = audio.get(tagname, None) if taglist: return taglist[ 0 ] else : return "" # TSOA def fill_tsoa (fpath): audio = EasyID3(fpath) artist = gettag (audio, "artist" ) if not artist: error ( "Missing artist in %s" % fpath) album = gettag (audio, "album" ) if not album: error ( "Missing album in %s" % fpath) year = gettag (audio, "date" ) if not year: error ( "Missing year in %s" % fpath) # TSOA tsoa = "%s -- %s - %s" % (artist, year, album) # EasyID3 . # TSOA albumsort. audio[ "albumsort" ] = tsoa audio.save() def fill_rec (root): # root # dirname. # fnames - dirname. # arg , . def process (arg, dirname, fnames): for fname in fnames: # Unicode fname = fname.decode( "cp1251" ) name, ext = path.splitext(fname) fname = path.join(dirname, fname) if path.isfile(fname) and ext.lower() == ".mp3" : try : fill_tsoa (fname) global totalfiles totalfiles = totalfiles + 1 print fname except ID3NoHeaderError: error ( "No tags in %s" % fname) # root # process; None # process . path.walk(root, process , None) if __name__ == "__main__" : # , , # . if sys .argv[ 1 :]: for dirname in sys .argv[ 1 :]: fill_rec (dirname) # , . else : fill_rec ( "." ) print "\nTotal files: %d" % totalfiles raw_input ();


You can copy the script to the directory with music and run without parameters. In this case, all mp3 files in the current directory and in all subdirectories will be processed. And you can independently transfer to the script in the form of parameters a list of necessary directories ( subdirectories will be processed in this case as well).

When the script finishes (it does not last too long), the data in the iTunes library will be updated. If these files you have not added there, then now is the time. If you edited tags in files already present in iTunes, you just need to select them in the iTunes window, open Get Info via the context menu and, without editing anything , click Ok . iTunes will simply update all tags from selected files.

AS IS


A few notes about the script:
  1. If you value your library, then it may be worthwhile to first test the script on several files — a lot of things can happen. I had a back-up of the entire collection, so I was not worried.
  2. It is possible that there may be problems when adding a too long string to the TSOA tag (I did not read the documentation on the internal structure of the tag block in mp3 files). The longest line in the TSOA tag (with my format is% artist% -% year% -% album%), which I happened to meet in my library, contained 93 characters. The tag was successfully saved in the file and everything was fine with it.
  3. The script easily processed 5,000 files with English names. I did not have Russian music in the library, but the test showed that tags are successfully added to the Cyrillic files in the title. In order to display the names of Russian-language files in the console (cmd) in a readable form, we had to add decoding of the name (line 58). It was under Windows, as under other axes - I do not know. Therefore, if you are not dealing with Russian file names, it is better to comment out this line.
  4. German and other names of files with diacritical marks I personally did not want to be processed. How to solve the problem, I have not yet figured out. The problem is that the file is called, for example, “Verf ü hrer.mp3”, and the script is called “Verf u hrer.mp3”. File with the same name in the folder, of course, no. Again, this is all Windows. Personally, I have diacritical marks in tags (there is Unicode and everything is fine), but I avoid them in the file names. Therefore, everything went well.

Afterword


If there are any other comments or problems - write. If there are suggestions how to solve problems with encodings, write even faster. To be honest, on all systems and in all languages, my entire conscious life constantly had problems with encodings. Maybe we are too different with them, but maybe I just need to sit down and deal with them all properly. One day I will definitely do it.

That's all for now. I would be glad if someone this script will be useful or at least interesting.

PS
Can anyone tell me what prompted sc.me to add a space in front of the zero in line 22? It was not in the source. If in html-e to remove in this place nbsp, then along with the space disappears and 0. And this is not good.

Source: https://habr.com/ru/post/83248/


All Articles