Guest

Untitled

By: a guest on Dec 1st, 2009  |  syntax: None  |  size: 3.79 KB  |  hits: 263  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. Project:
  2.         auto songs downloader
  3.  
  4. Abstract:
  5.         a python program that can scrape various web sites (funmaza.com, apniisp.com, songs.pk) and extract the links of all the songs, sorted by album.
  6.         it also downloads the files and saves them to appropriate directories. file tags (artist, album) are also set automatically.
  7.  
  8. Basic Design:
  9.         a two level design:
  10.         ==> at the first level is a backend that stores the details of the songs and albums. the storage can be in any format, but the interface
  11.                 exported is same for all backend storage formats. thus, a change in internal storage format should not break the application
  12.         ==> at the second level are various scripts for scrapping the web sites and adding the data to the backend.
  13.        
  14.         once the data is added, the files are downloaded, again using the backend interface to get the required info (song name, album, location, already downloaded?)
  15.         and the backend is updated appropriately.
  16.  
  17.         a GUI frontend is also present. it also uses the backend storage to show the data.
  18.  
  19.         no component except the backend handles the storage file directly. all requests go through the backend, thus making the system independant of the file format used to store the data.
  20.  
  21. BACKEND API:
  22.         ************************
  23.         BCKEND API START
  24.  
  25.         connect_to_file (file_name, callback)   # connects to the specified file to get data. if no file exists the callback is called, if it returns the STRING "TRUE" a new file is created
  26.                                                 # if it returns the STRING "FALSE", action is cancelled. if it returns any other STRING, connect_to_file () is called again with the string as the file_name
  27.         disconnect_from_file ()                 # disconnects the backend from the file, any further data exchanges are prohibited until a new file is connected to
  28.  
  29.         get_albums ()                           # returns a list containing (album_id, album_name) for each album
  30.         get_downloaded_albums ()                # return a list containing (album_id, album_name) for each album marked as downloaded
  31.         get_not_downloaded_albums ()            # inverse of get_downloaded_albums ()
  32.         get_album_location (album_id)           # returns the path of the folder for the album_id
  33.         get_album_artists (album_id)            # returns list of album artists
  34.  
  35.         get_songs ()                            # return a list containing (song_id, song_album_id, song_name) for each song
  36.         get_album_songs (album_id)              # returns a list containing (song_id, song_name) for each song from the given album
  37.         get_downloaded_songs ()                 # returns a list containing (song_id, song_album_id, song_name) for each song marked as downloaded
  38.         get_not_downloaded_songs ()             # inverse of get_downloaded_songs ()
  39.         get_song_location (song_id)             # returns the complete path (with filename) for the song_id
  40.         get_song_artists (album_id)             # returns list of song artists
  41.  
  42.         get_is_album_downloaded (album_id)      # returns TRUE if the album_id is marked as downloaded
  43.         get_is_song_downloaded (song_id)        # returns TRUE if the song_id is marked as downloaded
  44.         set_is_album_downloaded (album_id)      # changes the downloaded flag of the album_id
  45.         set_is_song_downloaded (song_id)        # changes the downloaded flag of the song_id
  46.  
  47.         add_album (album_name, album_location, downloaded, album_artists)       # adds a new album with the provided properties
  48.         add_song (song_name, song_location, downloaded, song_artists, album_id) # adds a new song with the provided properties
  49.        
  50.         delete_album (album_id, from_fs)        # deletes the album_id from DB. if from_fs is true, the album_location folder is also deleted
  51.         delete_song (song_id, from_fs)          # deletes the song_id from DB. if from_fs is true, the song_location file is also deleted
  52.  
  53.         find_album (album_name)                 # returns the album with the given album_name (exact case insensitive string match)
  54.         search_album (name)                     # return the album(s) with the given album_name (approximate match using Soundex {may change} algorithm)
  55.  
  56.         BCKEND API END
  57.         ************************