"tmsoup" Python extensions + enhancements

36 views
Skip to first unread message

D Gowers

unread,
Dec 8, 2014, 4:28:37 AM12/8/14
to tm...@googlegroups.com
Inspired by TMSU's recent migration to GitHub, I have created a repository for my TMSU related tools and modules:
https://github.com/0ion9/tmsoup

It has only one dependency:
Python 3.

The current main feature of tmsoup is an aliasing API and CLI.
The idea of an alias is, to map a name to one or more taggings.

Example aliasing uses are:
 * Quicker tagging : `fruit_salad` -> `apple banana orange`
 * Easier tagging : `music` -> `𝅘𝅥𝅮`
 * Tag=value shorthand : `2014` -> `year=2014`
 * Modify or simplify taggings as you import them : `soft rock`, `hard rock`, `progressive_rock` -> `rock`

The README at the above link explains how to setup an alias, which gives you easy command line access to alias functionality under the name 'talias'

The CLI is analogous to TMSU:

* you can add an alias like so:
`talias add fruit_salad apple banana orange`
* resolve a mixed list of aliases and tags into tags only with
`talias res fruit_salad pineapple` (output is `apple banana orange pineapple`). You can use this in conjunction with a tagging GUI, for example.
* list aliases with: `talias ls`
* remove the alias with:
`talias rm fruit_salad`
* other functions exist, try `talias -h` for a list

You can get help with 'talias -h' (toplevel help) or `talias $SUBCOMMAND -h` (help on a specific subcommand)



Technical details:

 * tmsoup.alias.init() adds two tables to your TMSU database if they don't already exist: 'alias' and 'alias_tag'; the former just maps ids to names, the latter maps alias ids to tag+value pairs. This is completely reversible by simply executing the SQL 'DROP TABLE alias; DROP TABLE alias_tag;`, if you so choose.
 * The API is fairly comprehensively demonstrated in tmsoup.alias.main(), which implements the CLI. Some reference to tmsoup.alias.parse_args() may be required. In general, the CLI is a pretty thin wrapper over the API: anything that is easy to do on CLI is also easy to do via API
 * Other API exists (tmsoup.core). tmsoup.alias uses it, but I make no claims that it is stable. It currently includes functions to:
  * get the correct database path (explicit path > TMSU_DB > default database path)
  * validate tag/value/alias names against the rules described in the TMSU wiki
  * Get a list of all tag names or tag values
  * Get a dict mapping id:tagname or tagname:id
  * Rename tags
  * No shelling-out to TMSU is involved, only sqlite3 interaction.

Enjoy.
 

Samuel Loury

unread,
Dec 10, 2014, 3:31:31 AM12/10/14
to D Gowers, tm...@googlegroups.com
D Gowers <fint...@gmail.com> writes:

> Inspired by TMSU's recent migration to GitHub, I have created a repository
> for my TMSU related tools and modules:
> https://github.com/0ion9/tmsoup

I like the initiative!

--
Konubinix
GPG Key : 7439106A
Fingerprint: 5993 BE7A DA65 E2D9 06CE 5C36 75D2 3CED 7439 106A
signature.asc

D Gowers

unread,
Dec 11, 2014, 11:28:28 PM12/11/14
to Samuel Loury, tm...@googlegroups.com
Thanks :)

I've just added API to tag files, which IIRC was one of the things you were looking for. It is not complete yet, in the sense that files that aren't already known to TMSU cannot be tagged. That will require a proper implementation of the various hashing algorithms TMSU implements. Functionality for untagging files that are already known to TMSU should come pretty soon, too.
Reply all
Reply to author
Forward
0 new messages