Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b203ab32f | ||
|
|
f3f308a812 | ||
|
|
ab4b572c98 | ||
|
|
b663390d9b | ||
|
|
1680d526ec | ||
|
|
add820b533 | ||
|
|
0c795ce69a | ||
|
|
cfb09d3154 | ||
|
|
cdb013d751 | ||
|
|
0269d7c1e4 | ||
|
|
573137ca71 | ||
|
|
601ce808da | ||
|
|
b44fe81bc9 | ||
|
|
1e0deaf23f | ||
|
|
fa10eba748 | ||
|
|
64ccf9f55c | ||
|
|
64fe0c97c2 | ||
|
|
f97b5ff98c | ||
|
|
f00e28a965 | ||
|
|
bf9680cb11 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,3 +4,4 @@ archive/
|
||||
config
|
||||
temp/
|
||||
test.py
|
||||
*.sh~
|
||||
|
||||
33
Branch_Scope.txt
Normal file
33
Branch_Scope.txt
Normal file
@@ -0,0 +1,33 @@
|
||||
2017-06-05 - Chris Bunt
|
||||
Automatic Ripping Mahcine (ARM) Project
|
||||
Development Branch: dep-omdbapi-key
|
||||
|
||||
Scope: Add the ability to query omdbapi using thier new API key structure. As
|
||||
of late May 2017, a change in policy at omdbapi requires the use of a key
|
||||
to perform queries. At this time, it is undetermined whether free (as in beer)
|
||||
access will be made again available, but if it is, it appears that it will
|
||||
still require a key.
|
||||
|
||||
This branch will update the code making the queries to get movie by type, which
|
||||
is used by the ARM to determine whether a video disc is a "movie" or a
|
||||
"TV series," (or potentially any other type of video).
|
||||
|
||||
API Key for OMDBAPI.com (Not sure how private this should be)
|
||||
OMDb API: http://www.omdbapi.com/?i=tt3896198&apikey=38d39b96
|
||||
Poster API: http://img.omdbapi.com/?i=tt3896198&h=600&apikey=38d39b96
|
||||
KEY: 38d39b96
|
||||
Generated URL:
|
||||
http://www.omdbapi.com/?t={0}&y={1}&plot=short&r=json&apikey={omdb_api_key
|
||||
http://www.omdbapi.com/?t="true grit"&plot=short&4=json&apikey=38d39b96
|
||||
video name example "Raising Arizona (1999)"
|
||||
|
||||
Files affected:
|
||||
|
||||
config.sample -- will likely need a new variable to support the eu's API key,
|
||||
this will be modelled off the exisitng API key methodology used for existing
|
||||
keyed tools like pushbullet and (presumably) MakeMKV.
|
||||
|
||||
getvideotype.py -- primary python script that gets the video type.
|
||||
|
||||
identify.sh -- Primary script that calls video type. Altered to pass the API
|
||||
key to getvideotype.py as part of the request
|
||||
@@ -158,6 +158,13 @@ IFTTT_EVENT="arm_event"
|
||||
PO_USER_KEY=""
|
||||
PO_APP_KEY=""
|
||||
|
||||
# OMDB_API_KEY
|
||||
# omdbapi.com API Key
|
||||
# This is the API key for omdbapi.com queries.
|
||||
# More info at http://omdbapi.com/
|
||||
# OMDB_API_KEY=""
|
||||
OMDB_API_KEY="38d39b96"
|
||||
|
||||
# Determine logfile name
|
||||
# use the label of the DVD/CD or else use empty.log
|
||||
# this is required for udev events where there is no media available
|
||||
|
||||
@@ -12,6 +12,7 @@ def entry():
|
||||
""" Entry to program, parses arguments"""
|
||||
parser = argparse.ArgumentParser(description='Get type of dvd--movie or tv series')
|
||||
parser.add_argument('-t', '--title', help='Title', required=True)
|
||||
parser.add_argument('-k', '--key', help='API_Key', dest='omdb_api_key', required=True)
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
@@ -20,6 +21,7 @@ def getdvdtype():
|
||||
or a tv series """
|
||||
dvd_title = args.title
|
||||
needs_new_year = "false"
|
||||
omdb_api_key = args.omdb_api_key
|
||||
|
||||
try:
|
||||
year = dvd_title[(dvd_title.rindex('(')):len(dvd_title)]
|
||||
@@ -38,7 +40,7 @@ def getdvdtype():
|
||||
if year is None:
|
||||
year = ""
|
||||
|
||||
dvd_type = callwebservice(dvd_title_clean, year)
|
||||
dvd_type = callwebservice(omdb_api_key, dvd_title_clean, year)
|
||||
# print (dvd_type)
|
||||
|
||||
# handle failures
|
||||
@@ -46,7 +48,7 @@ def getdvdtype():
|
||||
if (dvd_type == "fail"):
|
||||
|
||||
# first try submitting without the year
|
||||
dvd_type = callwebservice(dvd_title_clean, "")
|
||||
dvd_type = callwebservice(omdb_api_key, dvd_title_clean, "")
|
||||
# print (dvd_type)
|
||||
|
||||
if (dvd_type != "fail"):
|
||||
@@ -58,12 +60,12 @@ def getdvdtype():
|
||||
if (dvd_title.find("-") > -1):
|
||||
dvd_title_slice = dvd_title[:dvd_title.find("-")]
|
||||
dvd_title_slice =cleanupstring(dvd_title_slice)
|
||||
dvd_type = callwebservice(dvd_title_slice)
|
||||
dvd_type = callwebservice(omdb_api_key, dvd_title_slice)
|
||||
|
||||
# if still fail, then try slicing off the last word in a loop
|
||||
while dvd_type == "fail" and dvd_title_clean.count('+') > 0:
|
||||
dvd_title_clean = dvd_title_clean.rsplit('+', 1)[0]
|
||||
dvd_type = callwebservice(dvd_title_clean)
|
||||
dvd_type = callwebservice(omdb_api_key, dvd_title_clean)
|
||||
|
||||
if needs_new_year == "true":
|
||||
#pass the new year back to bash to handle
|
||||
@@ -77,13 +79,16 @@ def cleanupstring(string):
|
||||
string = string.strip()
|
||||
return re.sub('[_ ]',"+",string)
|
||||
|
||||
def callwebservice(dvd_title, year=""):
|
||||
def callwebservice(omdb_api_key, dvd_title, year=""):
|
||||
""" Queries OMDbapi.org for title information and parses if it's a movie
|
||||
or a tv series """
|
||||
# print (dvd_title)
|
||||
print (dvd_title)
|
||||
print (year)
|
||||
print (omdb_api_key)
|
||||
|
||||
try:
|
||||
dvd_title_info_json = urllib.request.urlopen("http://www.omdbapi.com/?t={0}&y={1}&plot=short&r=json".format(dvd_title, year)).read()
|
||||
# dvd_title_info_json = urllib.request.urlopen("http://www.omdbapi.com/?t={0}&y={1}&plot=short&r=json".format(dvd_title, year)).read()
|
||||
dvd_title_info_json = urllib.request.urlopen("http://www.omdbapi.com/?t={1}&y={2}&plot=short&r=json&apikey={0}".format(omdb_api_key, dvd_title, year)).read()
|
||||
except:
|
||||
return "fail"
|
||||
else:
|
||||
@@ -98,4 +103,4 @@ def callwebservice(dvd_title, year=""):
|
||||
args = entry()
|
||||
|
||||
dvd_type = getdvdtype()
|
||||
print(dvd_type)
|
||||
print(dvd_type)
|
||||
|
||||
@@ -70,8 +70,9 @@ if [ "$ID_FS_TYPE" == "udf" ]; then
|
||||
fi
|
||||
|
||||
if [ $HAS_NICE_TITLE == true ]; then
|
||||
VTYPE=$(/opt/arm/getvideotype.py -t "${VIDEO_TITLE}" 2>&1)
|
||||
|
||||
# VTYPE=$(/opt/arm/getvideotype.py -t "${VIDEO_TITLE}" 2>&1)
|
||||
VTYPE=$(/opt/arm/getvideotype.py -t "${VIDEO_TITLE}" -k "${OMDB_API_KEY}" 2>&1)
|
||||
|
||||
#handle year mismath if found
|
||||
if [[ $VTYPE =~ .*#.* ]]; then
|
||||
VIDEO_TYPE=$(echo "$VTYPE" | cut -f1 -d#)
|
||||
|
||||
Reference in New Issue
Block a user