Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/joemiller/xbmc-script-sort-movies-by-file-date

XBMC addon for sorting your Movie Library by the creation date from the movie files
https://github.com/joemiller/xbmc-script-sort-movies-by-file-date

Last synced: 13 days ago
JSON representation

XBMC addon for sorting your Movie Library by the creation date from the movie files

Awesome Lists containing this project

README

        

Purpose
-------

This script will re-sort your Media Libraries by looking at the timestamps
on your files.

The main use case for this would be to run this after you reset your XBMC
Library and all of your media are now sorted alphabetically instead of by
the date you added the files to your library.

This was inspired by my own personal needs, and apparantly many others
on this thread:
http://forum.xbmc.org/showthread.php?t=58525

(1/21/2012) Important Note: This plugin is only functional on XBMC 10.x (Dharma), it will
not work on 11.x (Eden) at this time. See here for additional discussion on why
and what we need to do before this will work on Eden: https://github.com/joemiller/xbmc-script-sort-movies-by-file-date/issues/4#issuecomment-3598657

How to install and run
----------------------
- Download a zip file from github by clicking on the Downloads link on
the github page at https://github.com/joemiller/xbmc-script-sort-movies-by-file-date

- Unzip the contents of the zip into a directory in your addons folder:

(Vista,Win7): c:\Users\\AppData\Roaming\XBMC\addons\script.sort-media

For other platforms, find your "special://home" path in the wiki:
http://wiki.xbmc.org/?title=Special_protocol

- Launch XBMC
- Go into "Programs"
- Execute "Sort Media Library"
- Re-launch XBMC (not required, but a good idea to reload the database)

This script should only be ran once, after you create your
media Library for the first time (or after you reset your library.), since
all future media added to the library will be added in the correct
chronological order.

How it works
------------
First, some background: The XBMC Libraries are contained in a SQLite (or MySQL)
database with each resource contained in a row in the respective table. There is
no timestamp in the database indicating "Date Added", instead, XBMC simply
relies on the order of the rows in the DB. This is why sorting by
Date Added looks more like sorting by alphabetical order when you
reset your library.

This script changes the order of the resources by modifiying the ID ('idMovie', 'idEpisode' etc.)
column in the respective table to be in the same order as the creation-timestamps
of the files themselves. The id of the resource is also changed in all the additional join tables,
the 'idFile' column is updated in all the required tables.

In order to accomplish this, the first thing the script will do is find the
largest id value in the media table. If you have 100 movies, then
the largest id will probably be 100. All of the ID's in the 'movie' table will
then be shifted from 1-100 to 101-200. The same is done for file ID's
('idFile') in the 'files' table.

Caveats:
--------
- Warning! I have only done limited testing on this script.

- It was tested on Windows 7, XBMC 10.0 and Linux, XBMC 10.1

- All of my movies were stored remotely via SMB. It works for local media,
too, but other protocols may or may not work.

- xbmc.makeLegalFilename() is called on each file returned from XBMC's
database before trying to access the file, but this may not work on
all platforms. Tested on Windows 7 with remote SMB files and on Linux
with local files.

Known Bugs
----------

To-Do
-----
- better/simpler installation. publish to official xbmc plugin repo
- support the Music Library, too
- localize the plugin properly
- enclose updates in a transaction
- handle cancel button in progress dialog

Author
------
Joe Miller - 1/23/2011
www.joeym.net

Michał (Saviq) Sawicz - 4/4/2011
[email protected]