google-code-export / beets

Automatically exported from code.google.com/p/beets
MIT License
0 stars 0 forks source link

Ignore OS-specific hidden files #293

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If you import an album with a hidden file in it. Like ".04 Boredom (Live at the 
Roxy).mp3.EqA3fj" than beets sees this file as a normal file and will not find 
any matches in Musicbrainz. 

Picard seems to make hidden files in Music folders similar to the one mentioned 
above, so it this can be inconvenient.   

example:

joris@i5:~$ beet -v import /Various\ Artists\ -\ Control\;\ Music\ from\ the\ 
Motion\ Picture\ -\ \[v0\]/
config file: /home/joris/.beetsconfig
library database: /home/joris/data/musiclibrary.blb
library directory: /mnt/nfs/Muziek
Looking up: /Various Artists - Control; Music from the Motion Picture - [v0]
Tagging Joy Division - Control: Music from the Motion Picture
Searching for discovered album ID: 8fffe80b-062f-4be0-8302-a9dc7161b744
Candidate: Various Artists - Control: Music from the Motion Picture
Too many items to match: 18 > 17.
Album ID match recommendation is RECOMMEND_NONE
Search terms: Joy Division - Control: Music from the Motion Picture
Album might be VA: True
Evaluating 10 candidates.
Candidate: Joy Division / New Order - Total: From Joy Division to New Order
Success. Distance: 0.712416
Candidate: Joy Division - Martin Hannett's Personal Mixes
Success. Distance: 0.728087
Candidate: Joy Division - Desperation Takes Hold
Success. Distance: 0.697605
Candidate: Joy Division - She's Lost Control
Too many items to match: 18 > 2.
Candidate: Joy Division - Words and Music
Too many items to match: 18 > 4.
Candidate: Various Artists - The Descendants: Music from the Motion Picture
Success. Distance: 0.715268
Candidate: Various Artists - The Descendants: Music from the Motion Picture
Success. Distance: 0.720248
Candidate: Various Artists - Winter's Bone: Music From the Motion Picture
Success. Distance: 0.724389
Candidate: Various Artists - Control: Music from the Motion Picture
Too many items to match: 18 > 17.
Candidate: Various Artists - スレイヤーズすぺしゃる: The Motion 
Picture "S"
Success. Distance: 0.794748

/Various Artists - Control; Music from the Motion Picture - [v0]
Finding tags for album "Joy Division - Control: Music from the Motion Picture".
Candidates:
1. Joy Division - Desperation Takes Hold (30.2%)
2. Joy Division / New Order - Total: From Joy Division to New Order [Rhino, 
2011] (28.8%)
3. Various Artists - The Descendants: Music from the Motion Picture (28.5%)
4. Various Artists - The Descendants: Music from the Motion Picture (28.0%)
5. Various Artists - Winter's Bone: Music From the Motion Picture [Cinewax, 
2010] (27.6%)
6. Joy Division - Martin Hannett's Personal Mixes [2007] (27.2%)
7. Various Artists - スレイヤーズすぺしゃる: The Motion Picture "S" 
(20.5%)
# selection (default 1), Skip, Use as-is, as Tracks, Enter search,
enter Id, aBort? B
Sending event: import

Original issue reported on code.google.com by Joris.Dobbelaer@gmail.com on 13 Jan 2012 at 7:58

GoogleCodeExporter commented 9 years ago
Thanks for the report. Fixed in 53d95ff0d917.

Original comment by adrian.sampson on 17 Jan 2012 at 1:10

GoogleCodeExporter commented 9 years ago
Though this is a start I don't think this is a complete solution yet. It will 
solve the problem on most *nix derivatives but doesn't do anything for Windows 
users where a file starting with a dot is nothing more than that, starting with 
a dot. Windows only hides files with the "hidden file" attribute flag and we 
just might want to check for that too.

Then there's also extended attributes and other things used to hide a file.

As an example on OS X:
>>> xattr.listxattr("Oasis - 05 - I'm Outta Time.mp3")
()

Chell daenney$ chflags hidden Oasis\ -\ 05\ -\ I\'m\ Outta\ Time.mp3 

>>> xattr.listxattr("Oasis - 05 - I'm Outta Time.mp3")
(u'com.apple.FinderInfo',)

I'd also expect os.stat("Oasis - 05 - I'm Outta Time.mp3) to show something in 
st_flags but that never seems to happen.

The even more interesting bit is that chflags hidden $file will hide that file 
in the Finder for you but will show it just fine on the command line.

Original comment by daniele.sluijters on 17 Jan 2012 at 6:47

GoogleCodeExporter commented 9 years ago
Just to add to it, stat actually sees a difference:
Chell: daenney$ stat Oasis\ -\ 05\ -\ I\'m\ Outta\ Time.mp3 
234881028 616417 -rw-r--r-- 1 daenney staff 0 3979928 "Jan 17 19:30:05 2012" 
"Jul  2 19:52:57 2011" "Jan 17 19:46:46 2012" "Jul  2 19:52:57 2011" 4096 7776 
0 Oasis - 05 - I'm Outta Time.mp3

Chell: daenney$ chflags hidden Oasis\ -\ 05\ -\ I\'m\ Outta\ Time.mp3 

Chell: daenney$ stat Oasis\ -\ 05\ -\ I\'m\ Outta\ Time.mp3 
234881028 616417 -rw-r--r-- 1 daenney staff 0 3979928 "Jan 17 19:30:05 2012" 
"Jul  2 19:52:57 2011" "Jan 17 19:53:55 2012" "Jul  2 19:52:57 2011" 4096 7776 
0x8000 Oasis - 05 - I'm Outta Time.mp3

Notice the 0x8000, that's st_flags. Why os.stat isn't picking up on that, no 
idea.

Original comment by daniele.sluijters on 17 Jan 2012 at 6:56

GoogleCodeExporter commented 9 years ago
Found it, you need to explicitly tell os.stat to give it to you:

>>> os.stat("/Users/daenney/Music/albums/Oasis/Oasis - [2008] Dig Out Your 
Soul/Oasis - 05 - I'm Outta Time.mp3").st_flags
0

Chell: daenney$ chflags hidden Oasis\ -\ 05\ -\ I\'m\ Outta\ Time.mp3 

>>> os.stat("/Users/daenney/Music/albums/Oasis/Oasis - [2008] Dig Out Your 
Soul/Oasis - 05 - I'm Outta Time.mp3").st_flags
32768

Original comment by daniele.sluijters on 17 Jan 2012 at 6:58

GoogleCodeExporter commented 9 years ago
That flag, 0x8000 in hex, is UF_HIDDEN:
http://docs.python.org/library/stat.html#stat.UF_HIDDEN
It's evidently a Mac OS X-specific stat flag.

For Windows hidden files, you apparently need the win32api module:
http://code.activestate.com/recipes/303343-changing-file-attributes-on-windows/

While we should eventually do this, I think skipping Windows and Mac "hidden" 
files is a little less important than .* files. In particular, many tools use 
.* files for temporary scratch files (.AppleDouble and the file reported above 
are examples), but as far as I know, Windows and Mac hidden files are generally 
just used to keep the user out of places they shouldn't be in the Finder and 
Windows Explorer. Anyway, it makes sense to do this eventually, but I haven't 
had any reports of beets getting confused by looking at hidden-flag files.

Original comment by adrian.sampson on 17 Jan 2012 at 7:54

GoogleCodeExporter commented 9 years ago

Original comment by adrian.sampson on 28 Nov 2012 at 4:27

untitaker commented 9 years ago

Do not comment here, but on sampsyo/beets#110