Skip to content

Commit

Permalink
Merge pull request #383 from lad1337/tvdb_api_update
Browse files Browse the repository at this point in the history
Tvdb api update
  • Loading branch information
midgetspy committed May 1, 2012
2 parents b3a7afe + 97044aa commit 450f51e
Show file tree
Hide file tree
Showing 19 changed files with 2,348 additions and 1,375 deletions.
2 changes: 2 additions & 0 deletions lib/tvdb_api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
*.pyc
9 changes: 9 additions & 0 deletions lib/tvdb_api/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: python
python:
- 2.5
- 2.6
- 2.7

install: pip install nose

script: nosetests
4 changes: 4 additions & 0 deletions lib/tvdb_api/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include UNLICENSE
include readme.md
include tests/*.py
include Rakefile
25 changes: 8 additions & 17 deletions lib/tvdb_api/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,14 @@ task :topypi => :test do
tvdb_api_version = cur_file.scan(/__version__ = "(.*)"/)
tvdb_api_version = tvdb_api_version[0][0].to_f

cur_file = File.open("tvnamer.py").read()
tvnamer_version = cur_file.scan(/__version__ = "(.*)"/)
tvnamer_version = tvnamer_version[0][0].to_f

puts "Build sdist and send tvdb_api v#{tvdb_api_version} and tvnamer v#{tvnamer_version} to PyPi?"
puts "Build sdist and send tvdb_api v#{tvdb_api_version} to PyPi?"
if $stdin.gets.chomp == "y"
puts "Sending source-dist (sdist) to PyPi"

FileUtils.mv("setup_tvdb_api.py", "setup.py")
if system("python setup.py sdist register upload")
print "tvdb_api uploaded!"
puts "tvdb_api uploaded!"
end
FileUtils.mv("setup.py", "setup_tvdb_api.py")

FileUtils.mv("setup_tvnamer.py", "setup.py")
if system("python setup.py sdist register upload")
puts "tvnamer uploaded!"
end
FileUtils.mv("setup.py", "setup_tvnamer.py")
else
puts "Cancelled"
end
Expand All @@ -92,14 +81,16 @@ end

task :test do
puts "Nosetest'ing"
if not system("nosetests -v")
if not system("nosetests -v --with-doctest")
raise "Test failed!"
end

puts "Doctesting *.py"
Dir.glob("*.py").each do |filename|
puts "Doctesting *.py (excluding setup.py)"
Dir.glob("*.py").select{|e| ! e.match(/setup.py/)}.each do |filename|
if filename =~ /^setup\.py/
skip
end
puts "Doctesting #{filename}"
puts "python", "-m", "doctest", filename
if not system("python", "-m", "doctest", filename)
raise "Failed doctest"
end
Expand Down
26 changes: 26 additions & 0 deletions lib/tvdb_api/UNLICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright 2011-2012 Ben Dickson (dbr)

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org/>
120 changes: 17 additions & 103 deletions lib/tvdb_api/readme.md
Original file line number Diff line number Diff line change
@@ -1,112 +1,25 @@
# `tvdb_api` and `tvnamer`
# `tvdb_api`

`tvdb_api` is an easy to use interface to [thetvdb.com][tvdb]

`tvnamer` is a utility which uses `tvdb_api` to rename files from `some.show.s01e03.blah.abc.avi` to `Some Show - [01x03] - The Episode Name.avi` (getting the episode name from `tvdb_api`)

## To install

You can easily install `tvnamer` via `easy_install`

easy_install tvnamer

This installs the `tvnamer` command-line tool (and the `tvdb_api` module as a requirement)
`tvnamer` has moved to a separate repository: [github.com/dbr/tvnamer][tvnamer] - it is a utility which uses `tvdb_api` to rename files from `some.show.s01e03.blah.abc.avi` to `Some Show - [01x03] - The Episode Name.avi` (which works by getting the episode name from `tvdb_api`)

You may need to use sudo, depending on your setup:
[![Build Status](https://secure.travis-ci.org/dbr/tvdb_api.png?branch=master)](http://travis-ci.org/dbr/tvdb_api)

sudo easy_install tvnamer
## To install

If you wish to only install the `tvdb_api` Python module,
You can easily install `tvdb_api` via `easy_install`

easy_install tvdb_api

# `tvnamer`

## Basic usage

From the command line, simply run:

tvnamer the.file.s01e01.avi

For example:

$ tvnamer scrubs.s01e01.avi
####################
# Starting tvnamer
# Processing 1 files
# ..got tvdb mirrors
# Starting to process files
####################
# Processing scrubs (season: 1, episode 1)
TVDB Search Results:
1 -> Scrubs # http://thetvdb.com/?tab=series&id=76156
Automatically selecting only result
####################
Old name: scrubs.s01e01.avi
New name: Scrubs - [01x01] - My First Day.avi
Rename?
([y]/n/a/q)

Enter `y` then press `return` and the file will be renamed to "Scrubs - [01x01] - My First Day.avi". You can also simply press `return` to select the default option, denoted by the surrounding `[]`

If there are multiple shows with the same (or similar) names, you will be asked to select the correct one - "Lost" is a good example of this:

$ python tvnamer.py lost.s01e01.avi
####################
# Starting tvnamer
# Processing 1 files
# ..got tvdb mirrors
# Starting to process files
####################
# Processing lost (season: 1, episode 1)
TVDB Search Results:
1 -> Lost # http://thetvdb.com/?tab=series&id=73739
2 -> Lost in Space # http://thetvdb.com/?tab=series&id=72923
[...]
Enter choice (first number, ? for help):

To select the first result, enter `1` then `return`, to select the second enter `2` and so on. The link after `#` goes to the relevant [thetvdb.com][tvdb] page, which will contain information and images to help you select the correct series.

You can rename multiple files, or an entire directory by using the files or directories as arguments:

$ tvnamer file1.avi file2.avi etc
$ tvnamer .
$ tvnamer /path/to/my/folder/
$ tvnamer ./folder/1/ ./folder/2/

You can skip a specific file by entering `n` (no). If you enter `a` (always) `tvnamer` will rename the remaining files automatically. The suggested use of this is check the first few episodes are named correctly, then use `a` to rename the rest.

Note, tvnamer will only descend one level into directories unless the `-r` (or `--recursive`) flag is specified. For example, if you have the following directory structure:

dir1/
file1.avi
dir2/
file2.avi
file3.avi

..then running `tvnamer dir1/` will only rename `file1.avi`, ignoring `dir2/` and its contents.

If you wish to rename all files (file1, file2 and file3), you would run:

tvnamer --recursive dir1/

## Advanced usage

There are various flags you can use with `tvnamer`, run..

tvnamer --help

..to see them, and a short description of each.

The most interesting are most likely `--batch`, `--selectfirst` and `--always`:
You may need to use sudo, depending on your setup:

`--selectfirst` will select the first series the search found, but will not automatically rename any episodes.
sudo easy_install tvdb_api

`--always` will ask you select the correct series, then automatically rename all files.
The [`tvnamer`][tvnamer] command-line tool can also be installed via `easy_install`, this installs `tvdb_api` as a dependancy:

`--batch` will not prompt you for anything. It automatically selects the first series search result, and automatically rename all files. Use carefully!
easy_install tvnamer

# `tvdb_api`

## Basic usage

Expand Down Expand Up @@ -145,17 +58,17 @@ All data exposed by [thetvdb.com][tvdb] is accessible via the `Show` class. A Sh
For example, to find out what network Scrubs is aired:

>>> t['scrubs']['network']
u'NBC|ABC'
u'ABC'

The data is stored in an attribute named `data`, within the Show instance:

>>> t['scrubs'].data.keys()
['networkid', 'rating', 'airs_dayofweek', 'contentrating', 'seriesname', 'id', 'airs_time', 'network', 'fanart', 'lastupdated', 'actors', 'overview', 'status', 'added', 'poster', 'imdb_id', 'genre', 'banner', 'seriesid', 'language', 'zap2it_id', 'addedby', 'firstaired', 'runtime']
['networkid', 'rating', 'airs_dayofweek', 'contentrating', 'seriesname', 'id', 'airs_time', 'network', 'fanart', 'lastupdated', 'actors', 'ratingcount', 'status', 'added', 'poster', 'imdb_id', 'genre', 'banner', 'seriesid', 'language', 'zap2it_id', 'addedby', 'firstaired', 'runtime', 'overview']

Although each element is also accessible via `t['scrubs']` for ease-of-use:

>>> t['scrubs']['rating']
u'9.1'
u'9.0'

This is the recommended way of retrieving "one-off" data (for example, if you are only interested in "seriesname"). If you wish to iterate over all data, or check if a particular show has a specific piece of data, use the `data` attribute,

Expand All @@ -166,6 +79,7 @@ This is the recommended way of retrieving "one-off" data (for example, if you ar

Since banners and actors are separate XML files, retrieving them by default is undesirable. If you wish to retrieve banners (and other fanart), use the `banners` Tvdb initialisation argument:

>>> from tvdb_api import Tvdb
>>> t = Tvdb(banners = True)

Then access the data using a `Show`'s `_banner` key:
Expand All @@ -180,16 +94,16 @@ Extended actor data is accessible similarly:
>>> t = Tvdb(actors = True)
>>> actors = t['scrubs']['_actors']
>>> actors[0]
>>> actors[0]
<Actor "Zach Braff">
>>> actors[0].keys()
['image', 'sortorder', 'role', 'id', 'name']
['sortorder', 'image', 'role', 'id', 'name']
>>> actors[0]['role']
u'Dr. John Michael "J.D." Dorian'

Remember a simple list of actors is accessible via the default Show data:

>>> t['scrubs']['actors']
u'|Zach Braff|Donald Faison|Sarah Chalke|Christa Miller Lawrence|Aloma Wright|Robert Maschio|Sam Lloyd|Neil Flynn|Ken Jenkins|Judy Reyes|John C. McGinley|'
u'|Zach Braff|Donald Faison|Sarah Chalke|Christa Miller|Aloma Wright|Robert Maschio|Sam Lloyd|Neil Flynn|Ken Jenkins|Judy Reyes|John C. McGinley|Travis Schuldt|Johnny Kastl|Heather Graham|Michael Mosley|Kerry Bish\xe9|Dave Franco|Eliza Coupe|'

[tvdb]: http://www.thetvdb.com
[tvdb]: http://www.thetvdb.com
[tvnamer]: http://github.com/dbr/tvnamer
9 changes: 4 additions & 5 deletions lib/tvdb_api/setup_tvdb_api.py → lib/tvdb_api/setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from setuptools import setup
setup(
name='tvdb_api',
version='1.0',
name = 'tvdb_api',
version='1.6.4',

author='dbr/Ben',
description='Interface to thetvdb.com',
url='http://github.com/dbr/tvdb_api/tree/master',
license='GPLv2',
license='unlicense',

long_description="""\
An easy to use API interface to TheTVDB.com
Expand All @@ -21,11 +21,10 @@
u'Stole a Badge'
""",

py_modules=['tvdb_api', 'tvdb_ui', 'tvdb_exceptions', 'cache'],
py_modules = ['tvdb_api', 'tvdb_ui', 'tvdb_exceptions', 'tvdb_cache'],

classifiers=[
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
Expand Down
35 changes: 0 additions & 35 deletions lib/tvdb_api/setup_tvnamer.py

This file was deleted.

Loading

0 comments on commit 450f51e

Please sign in to comment.