Skip to content

Commit

Permalink
Revert "Merge pull request #383 from lad1337/tvdb_api_update"
Browse files Browse the repository at this point in the history
  • Loading branch information
midgetspy committed May 1, 2012
1 parent 450f51e commit 4334df7
Show file tree
Hide file tree
Showing 19 changed files with 1,375 additions and 2,348 deletions.
2 changes: 0 additions & 2 deletions lib/tvdb_api/.gitignore

This file was deleted.

9 changes: 0 additions & 9 deletions lib/tvdb_api/.travis.yml

This file was deleted.

4 changes: 0 additions & 4 deletions lib/tvdb_api/MANIFEST.in

This file was deleted.

25 changes: 17 additions & 8 deletions lib/tvdb_api/Rakefile
Expand Up @@ -52,14 +52,25 @@ task :topypi => :test do
tvdb_api_version = cur_file.scan(/__version__ = "(.*)"/)
tvdb_api_version = tvdb_api_version[0][0].to_f

puts "Build sdist and send tvdb_api v#{tvdb_api_version} to PyPi?"
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?"
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")
puts "tvdb_api uploaded!"
print "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 @@ -81,16 +92,14 @@ end

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

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 *.py"
Dir.glob("*.py").each do |filename|
puts "Doctesting #{filename}"
puts "python", "-m", "doctest", filename
if not system("python", "-m", "doctest", filename)
raise "Failed doctest"
end
Expand Down
26 changes: 0 additions & 26 deletions lib/tvdb_api/UNLICENSE

This file was deleted.

5 changes: 3 additions & 2 deletions lib/tvdb_api/tvdb_cache.py → lib/tvdb_api/cache.py 100755 → 100644
Expand Up @@ -3,7 +3,8 @@
#author:dbr/Ben
#project:tvdb_api
#repository:http://github.com/dbr/tvdb_api
#license:unlicense (http://unlicense.org/)
#license:Creative Commons GNU GPL v2
# (http://creativecommons.org/licenses/GPL/2.0/)

"""
urllib2 caching handler
Expand All @@ -12,7 +13,7 @@
from __future__ import with_statement

__author__ = "dbr/Ben"
__version__ = "1.6.4"
__version__ = "1.5"

import os
import time
Expand Down
120 changes: 103 additions & 17 deletions lib/tvdb_api/readme.md
@@ -1,25 +1,112 @@
# `tvdb_api`
# `tvdb_api` and `tvnamer`

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

`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`)

[![Build Status](https://secure.travis-ci.org/dbr/tvdb_api.png?branch=master)](http://travis-ci.org/dbr/tvdb_api)
`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 `tvdb_api` via `easy_install`
You can easily install `tvnamer` via `easy_install`

easy_install tvdb_api
easy_install tvnamer

This installs the `tvnamer` command-line tool (and the `tvdb_api` module as a requirement)

You may need to use sudo, depending on your setup:

sudo easy_install tvdb_api
sudo easy_install tvnamer

The [`tvnamer`][tvnamer] command-line tool can also be installed via `easy_install`, this installs `tvdb_api` as a dependancy:
If you wish to only install the `tvdb_api` Python module,

easy_install tvnamer
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`:

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

`--always` will ask you select the correct series, then automatically rename all files.

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

# `tvdb_api`

## Basic usage

Expand Down Expand Up @@ -58,17 +145,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'ABC'
u'NBC|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', 'ratingcount', 'status', 'added', 'poster', 'imdb_id', 'genre', 'banner', 'seriesid', 'language', 'zap2it_id', 'addedby', 'firstaired', 'runtime', 'overview']
['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']

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

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

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 @@ -79,7 +166,6 @@ 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 @@ -94,16 +180,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()
['sortorder', 'image', 'role', 'id', 'name']
['image', 'sortorder', '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|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|'
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|'

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

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

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

py_modules = ['tvdb_api', 'tvdb_ui', 'tvdb_exceptions', 'tvdb_cache'],
py_modules=['tvdb_api', 'tvdb_ui', 'tvdb_exceptions', '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: 35 additions & 0 deletions lib/tvdb_api/setup_tvnamer.py
@@ -0,0 +1,35 @@
from setuptools import setup
setup(
name='tvnamer',
version='1.0',

author='dbr/Ben',
description='Automatic TV episode namer',
url='http://github.com/dbr/tvdb_api/tree/master',
license='GPLv2',

long_description="""\
Automatically names downloaded/recorded TV-episodes, by parsing filenames and retrieving show-names from www.thetvdb.com
Relies on tvdb_api
""",

py_modules=['tvnamer'],
entry_points={
'console_scripts':[
'tvnamer = tvnamer:main'
]
},

install_requires=['tvdb_api==1.0'],

classifiers=[
"Environment :: Console",
"Intended Audience :: End Users/Desktop",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Topic :: Multimedia",
"Topic :: Utilities"
]
)

0 comments on commit 4334df7

Please sign in to comment.