foo. bar. baz. quux.

Foobar2000:Playlist Tree:Examples

From WikiBazQuux

(Redirected from Example Queries)
Jump to: navigation, search

Contents

Now Playing

example_hidden.png
Returns the albums of the now playing artist, and hides all albums with more than 8 tracks.

By Directory

Using Drop Query

by_directory.png

Using Database

by_directory_2.png

Most Played

Assumes your files are tagged with a %playcount% tag representing the number of times played.

most_played.png

Filling an mp3 player with random songs

You might also make a restriction so such as $ext(%_path%) IS mp3

mp3_player_filler.png

Hour of Random Music

random_hour.png

hi_rating_random_hour.png
a random hour of music rated 4 or higher

Recently Played

Requires foo_cwb_hooks and the offical play_count plugin

query_recently_played.png

Sample Query Criteria

  • Rating > 3 and has not been played in over a week (Requires foo_cwb_hooks and the offical play_count plugin)
rating GREATER 3 AND ("$cwb_datediff(%last_played%,%cwb_systemdate%)" GREATER 7 OR NOT %last_played% HAS 20)
  • 2005 Tracks
%_path% HAS 2005 OR date HAS 2005
  • Singles
("single title" IS *) OR (_replaygain_album_gain MISSING) AND (_replaygain_track_gain IS *)

Sample Formats

@scheme Queries

Every DB Entry

(for-each-db-entry
 (lambda (handle) 
   (add-node 
    handle
    (list (format-title handle "%artist%")
	  (format-title handle "%album%")
	  (format-title handle "%title%")))))

Beatles

(for-each-db-entry
 (lambda (handle) 
   (add-node 
    handle
    (list (format-title handle "%artist%")
	  (format-title handle "%album%")
	  (format-title handle "%title%"))))
 "artist HAS beatles")

Hours worth of Beatles

(let ((total-time 0))
  (for-each-db-entry
   (lambda (handle) 
     (let ((len (get-length handle)))
       (if (< (+ len total-time) (* 60 60))
	   (begin
	     (add-node 
	      handle
	      (list (format-title handle "%artist%")
		    (format-title handle "%album%")
		    (format-title handle "%title%")))
	     (set! total-time (+ total-time len))))))
   "artist HAS beatles"))

All playlist entries

(for-each-playlist 
 (lambda (n) 
   (for-each-playlist-entry 
    n
    (lambda (handle) 
      (add-node 
       handle
       (list 
	n
	(format-title handle "%artist% - %title%")))))))

Random Hours Based on Ratings

(let ((random-hour
       (lambda (label criteria)
	 (display label)
	 (let ((total-time 0)
	       (leaf-format "%artist% - %title% '('%rating%')'")
	       (time-limit (* 60 60)))
	   (for-each-db-entry
	    (lambda (handle) 
	      (let ((len (get-length handle)))
		(if (< (+ len total-time) (* 60 60))
		    (begin
		      (add-node 
		       handle
		       (list label
			     (format-title handle leaf-format)))
		      (set! total-time (+ total-time len))))))
	    criteria "$rand()")))))
  (random-hour "Great Stuff" "rating GREATER 4")
  (random-hour "Good Stuff" "rating GREATER 3")
  (random-hour "Decent Stuff" "rating GREATER 2"))

Hours worth of favorite artists

(let ((query-string "")
      (favorite-artists 
       ;;; Note that you can add whatever artists you want into this list
       (list "Jude" "Beatles" "The Beatles" 
	     "Nathan Caswell" "Jimmy Buffett" 
	     "Brian Vander Ark" "Verve Pipe" "The Verve Pipe"
	     "Bob Dylan"))
      (random-hour
       (lambda (label criteria)
	 (let ((total-time 0)
	       (leaf-format "%artist% - %title% '('%rating%')'")
	       (time-limit (* 60 60)))
	   (for-each-db-entry
	    (lambda (handle) 
	      (let ((len (get-length handle)))
		(if (< (+ len total-time) (* 60 60))
		    (begin
		      (add-node 
		       handle
		       (list label
			     (format-title handle leaf-format)))
		      (set! total-time (+ total-time len))))))
	    criteria
	    "$rand()")))))
  (for-each 
   (lambda (artist)
     (set! query-string 
	   (if (= (string-length query-string) 0)
	       (string-append "(artist IS " artist ")")
	       (string-append query-string  " OR (artist IS " artist ")"))))
   favorite-artists)
  (set! query-string 
	(string-append "rating GREATER 2 AND (" query-string ")"))
  (write query-string)
  (random-hour "Favs" query-string))

Example of a nested query

(let ((source "@database")
      (format "%artist% - %title% '('%rating%')'")
      (pop-sort "$rand()")
      (max 60)
      (max-type tree-max-minutes)
      (not-recent 
       "(\"$cwb_datediff(%last_played%,%cwb_systemdate%)\" GREATER 7 OR NOT %last_played% HAS 20)"))
  (for-each 
   (lambda (label criteria)
     (refresh-query 
      (add-query-node label source criteria format pop-sort #f max max-type)))
   (list "Great Stuff" "Good Stuff" "Decent Stuff")
   (map (lambda (c)
	  (string-append c " AND " not-recent))
	(list "rating GREATER 4" "rating GREATER 3" "rating GREATER 2"))))

More

;;; Fill *Scheme* playlist with an hours worth 
(let ((playlist-index (find-or-create-playlist "*Scheme*"))
      (total-time 0))
  (clear-playlist playlist-index)
  (for-each-db-entry
   (lambda (handle) 
     (let ((len (get-length handle)))
       (if (< (+ len total-time) (* 60 60))
	   (begin
	     (add-to-playlist handle playlist-index)
	     (set! total-time (+ total-time len))))))
   "rating GREATER 3"
   "$rand()")
  (activate-playlist playlist-index)
  (play-from-playlist playlist-index))
;;; Show properties of all playlist entries
(let ((the-list (list)))
  (for-each-playlist 
   (lambda (n) 
     (for-each-playlist-entry 
      n
      (lambda (handle) 
	(set! the-list 
	      (cons handle the-list))))))
  (contextmenu "Properties" the-list))


HARDCORE

;;; Fill *Scheme* playlist with an hours worth, no repeat on artist
(letrec ((playlist-index (find-or-create-playlist "*Scheme*"))
	 (total-time 0)
	 (filter-string "rating GREATER 3")
	 (artist-list (list))
	 (intersect? 
	  (lambda (a b)
	    (cond
	     ((null? a) #f)
	     ((member (car a) b) #t)
	     (#t (intersect? (cdr a) b))))))
  (clear-playlist playlist-index)
  (for-each-db-entry
   (lambda (handle) 
     (let* ((len (get-length handle))
	    (artists (meta-list handle "artist"))
	    (add 
	     (lambda (h)
	       (set! artist-list (append artists artist-list))
	       (add-to-playlist h playlist-index)
	       (set! total-time (+ total-time len)))))
       (if (and (< (+ len total-time) (* 60 60))
		(not (intersect? artists artist-list)))
	   (add handle))))
   filter-string
   "$rand()")
  (activate-playlist playlist-index)
  (play-from-playlist playlist-index)
  (write artist-list))
Personal tools