20 Commits

Author SHA1 Message Date
Aaron Helton
1b203ab32f Add omdb_api_key to the format call for proper request. 2017-06-06 00:09:29 -04:00
Chris A. Bunt
f3f308a812 Propogating new variable throughout all function calls 2017-06-05 21:30:36 -05:00
Chris A. Bunt
ab4b572c98 minor syntax updates 2017-06-05 18:54:54 -05:00
Chris A. Bunt
b663390d9b still adding variable locations 2017-06-05 18:51:10 -05:00
Chris A. Bunt
1680d526ec adding variable pass to another function
still learning...
2017-06-05 18:45:50 -05:00
Chris A. Bunt
add820b533 rearrange default vs. non-default arguments
Learning about Python through the school of hard knocks and intepretive
syntax errors
2017-06-05 18:36:22 -05:00
Chris A. Bunt
0c795ce69a parsing args and add debug 2017-06-05 18:18:41 -05:00
Chris A. Bunt
cfb09d3154 add new line of code with updated request line
First pass at this query
2017-06-05 17:59:30 -05:00
Chris A. Bunt
cdb013d751 Add argument to parser in the correct file
Put new line of code in the correct file this time!
2017-06-05 17:49:07 -05:00
Chris A. Bunt
0269d7c1e4 Revert "Add argument to line parse"
This reverts commit 573137ca71.
2017-06-05 17:47:49 -05:00
Chris A. Bunt
573137ca71 Add argument to line parse 2017-06-05 17:36:38 -05:00
Chris A. Bunt
601ce808da Add OMDB_API_KEY back to config.sample 2017-06-05 17:18:01 -05:00
root
b44fe81bc9 Merge branch 'dep-omdbapi-key' of https://github.com/cbunt1/automatic-ripping-machine into dep-omdbapi-key 2017-06-05 22:16:16 +00:00
root
1e0deaf23f revert to original python file 2017-06-05 22:13:45 +00:00
Chris A. Bunt
fa10eba748 Revert "add variable to config file"
This reverts commit f97b5ff98c.
2017-06-05 17:00:21 -05:00
Chris A. Bunt
64ccf9f55c removing whitespace, setup debug 2017-06-05 16:52:05 -05:00
Chris A. Bunt
64fe0c97c2 first pass at adding key 2017-06-05 16:35:23 -05:00
root
f97b5ff98c add variable to config file 2017-06-05 19:50:25 +00:00
Chris A. Bunt
f00e28a965 key info and methodology 2017-06-05 14:40:23 -05:00
Chris A. Bunt
bf9680cb11 Initlal commit
Adding a branch scope file and starting the commit/develop process
2017-06-05 13:14:03 -05:00
5 changed files with 57 additions and 10 deletions

1
.gitignore vendored
View File

@@ -4,3 +4,4 @@ archive/
config
temp/
test.py
*.sh~

33
Branch_Scope.txt Normal file
View 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

View File

@@ -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

View File

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

View File

@@ -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#)