Skip to content

Commit

Permalink
Merge pull request #3 from tkdan235/dupes
Browse files Browse the repository at this point in the history
Delete Dupes
  • Loading branch information
danb235 committed Jan 14, 2015
2 parents 797b7cd + 5218459 commit 44e3167
Show file tree
Hide file tree
Showing 8 changed files with 242 additions and 140 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ Point **mediatidy** at your movie or TV show directory and it will do the follow
* Delete all non-video type files
* Delete all corrupt/incomplete video files
* Delete all sample files
* Process files to find dupes; keep the highest quality of the dupes and delete the rest

Coming soon:
* Delete files under a specified size
* Process files to find dupes; keep the highest resolution of the dupes and delete the rest
* Process files to find dupes; keep the largest sized file of the dupes (if they are the same resolution) and delete the rest
* Delete empty directories

<!-- ## Current Assumptions
Expand Down Expand Up @@ -44,13 +43,13 @@ sudo npm install -g mediatidy
Add media folder to **mediatidy** you would like to process with:

```
mediatidy config paths-update
mediatidy paths-update
```

Let's tidy up those media directories!

```
mediatidy media update
mediatidy update
```

As always options etc. can be brought up with:
Expand Down
96 changes: 91 additions & 5 deletions bin/mediatidy
Original file line number Diff line number Diff line change
@@ -1,13 +1,99 @@
#!/usr/bin/env coffee

program = require 'commander'
pkg = require '../package.json'
path = require 'path'
program = require 'commander'
Config = require '../lib/config'
Media = require '../lib/media'
colors = require 'colors'
async = require 'async'

program.version(pkg.version)

program.command('update')
.description('look for for files and directories and add to mediatidy database')
.action () ->
media = new Media

# Perform action in series with async
async.series [
(callback) ->
media.setup ->
callback()
(callback) ->
media.addFiles ->
callback()
(callback) ->
media.exists ->
callback()
(callback) ->
media.fileMetaUpdate ->
callback()
(callback) ->
media.deleteCorrupt ->
callback()
(callback) ->
media.deleteSamples ->
callback()
(callback) ->
media.deleteOthers ->
callback()
(callback) ->
media.deleteDupes ->
callback()
], (err, results) ->
throw err if err
console.log 'Media update complete.'

program
.command('paths-update')
.description('update paths to media files for mediatidy to tidy up!')
.action () ->
config = new Config

async.series [
(seriesCallback) ->
config.setup ->
seriesCallback()
(seriesCallback) ->
config.pathPrompt ->
seriesCallback()
], (err, results) ->
throw err if err
console.log 'path update complete.'

program
.command('paths-clear')
.description('clear paths to media files for mediatidy')
.action () ->
config = new Config

async.series [
(seriesCallback) ->
config.setup ->
seriesCallback()
(seriesCallback) ->
config.pathsDelete ->
seriesCallback()
], (err, results) ->
throw err if err
console.log 'path clear complete.'

program
.version(pkg.version)
.command('media <action>', 'perform media file <action> such as tidy')
.command('config <action>', 'perform config <action> such as paths-update')
.command('files-clear')
.description('purge all media files from the database')
.action () ->
config = new Config

async.series [
(seriesCallback) ->
config.setup ->
seriesCallback()
(seriesCallback) ->
config.filesDelete ->
seriesCallback()
], (err, results) ->
throw err if err
console.log 'files clear complete.'

program.parse(process.argv)

Expand Down
64 changes: 0 additions & 64 deletions bin/mediatidy-config

This file was deleted.

46 changes: 0 additions & 46 deletions bin/mediatidy-media

This file was deleted.

6 changes: 3 additions & 3 deletions lib/config.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Config extends Database
# get the simple yes or no property
prompt.get ['yesno'], (err, result) =>
if result.yesno.match(/yes/i)
@dbBulkFileDelete =>
@dbFileTableDeleteAll =>
console.log "All files removed from mediatidy..."
callback()
else
Expand Down Expand Up @@ -113,8 +113,8 @@ class Config extends Database
prompt.delimiter = ": ".green
prompt.properties =
path:
description: 'enter full path to media files (movies or tv shows)'
message: 'enter path to media files'
description: 'full path to media files (example: /Volumes/Movies)'
pattern: /^\/\w+/
required: true

prompt.start()
Expand Down
6 changes: 6 additions & 0 deletions lib/db.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ class Database
db.close ->
callback rows

dbFileTableDeleteAll: (callback) ->
db = new sqlite3.Database(@dbFile)
db.run "DELETE FROM MEDIAFILES", ->
db.close ->
callback()

dbPathAdd: (path, tag, callback) ->
db = new sqlite3.Database(@dbFile)

Expand Down
Loading

0 comments on commit 44e3167

Please sign in to comment.