Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Commit

Permalink
Encode Url
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaavalon committed Jan 18, 2018
1 parent 6705f22 commit 7eb0602
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Contents/Code/helper.py
@@ -1,6 +1,7 @@
from os.path import dirname, join, splitext, exists, basename
import re
import urllib2
import urllib

from log import *

Expand Down Expand Up @@ -167,21 +168,25 @@ def select_exist(*args):

def put_update(media_id, title, tagline):
token = Prefs["Token"]
if (title is None and tagline is None) or not token:
if not token:
return
pageUrl = "http://127.0.0.1:32400/library/metadata/" + media_id
xml_element = XML.ElementFromURL(pageUrl)
section = String.Unquote(xml_element.xpath("//MediaContainer")[0].get("librarySectionID").encode("utf-8"))
opener = urllib2.build_opener(urllib2.HTTPHandler)
request_url = "http://127.0.0.1:32400/library/sections/" + section + "/all?type=2&id=" + media_id + "&X-Plex-Token=" + token
query = {"type": "2", "id": media_id, "X-Plex-Token": token, "originalTitle.locked": "0", "tagline.locked": "0"} # Movie Type 1
request_url = "http://127.0.0.1:32400/library/sections/" + section + "/all?"
if title is not None:
request_url += "&originalTitle.value=" + title
query["originalTitle.value"] = title
if tagline is not None:
request_url += "&tagline.value=" + tagline
query["tagline.value"] = tagline
request_url += urllib.urlencode(query)
PlexLog.warn("request_url %s" % request_url)
request = urllib2.Request(request_url)
request.get_method = lambda: 'PUT'
try:
url = opener.open(request)
url.read()
except HTTPError as e:
PlexLog.error(e.strerror)
except urllib2.HTTPError as e:
PlexLog.error("request_url %s" % request_url)
PlexLog.error(str(e))

0 comments on commit 7eb0602

Please sign in to comment.