PRODUCT_NAME = 'armadillo'
# The Golang version (hg id).
-BACK_END_COMPILER_VERSION = '95d2ce135523 (release-branch.r57) release/release.r57.1'
+BACK_END_COMPILER_VERSION = 'c1702f36df03 (release-branch.r60) release/release.r60.3'
COMPILER = '6g'
LINKER = '6l'
"os"
"path"
"strings"
+ "url"
"./config"
"./paths"
"./tv_rename"
errorResponse(response, err.String())
} else {
data := map[string]interface{}{
- "path": path,
+ "path": path,
"error": 0,
}
okResponse(response, data)
return
}
- url, err := http.ParseURL(rawURL)
+ url_, err := url.Parse(rawURL)
if err != nil {
errorResponse(response, err.String())
return
}
- err = performProxy(url, response, request)
+ err = performProxy(url_, response, request)
if err != nil {
errorResponse(response, err.String())
}
}
-func performProxy(url *http.URL, response http.ResponseWriter, origRequest *http.Request) os.Error {
- conn, err := net.Dial("tcp", url.Host+":http")
+func performProxy(url_ *url.URL, response http.ResponseWriter, origRequest *http.Request) os.Error {
+ conn, err := net.Dial("tcp", url_.Host+":http")
if err != nil {
return err
}
client := http.NewClientConn(conn, nil)
var request http.Request
- request.URL = url
+ request.URL = url_
request.Method = "GET"
- request.UserAgent = origRequest.UserAgent
+ request.Header.Set("User-Agent", origRequest.UserAgent())
err = client.Write(&request)
if err != nil {
return err
func downloadHandler(response http.ResponseWriter, request *http.Request) {
valid, fullPath := paths.IsValid(request.FormValue("path"))
if valid {
- info, _ := os.Lstat(fullPath) // Error is already checked by |valid|.
+ info, _ := os.Lstat(fullPath) // Error is already checked by |valid|.
if info.IsDirectory() {
http.Error(response, "Path is a directory", http.StatusBadRequest)
} else {
func RunBackEnd(config *config.Configuration) {
mux := http.NewServeMux()
mux.HandleFunc("/", indexHandler)
- mux.Handle("/fe/", http.FileServer(kFrontEndFiles, "/fe/"))
+ mux.Handle("/fe/", http.StripPrefix("/fe/", http.FileServer(http.Dir(kFrontEndFiles))))
mux.HandleFunc("/service", serviceHandler)
mux.HandleFunc("/download", downloadHandler)
mux.HandleFunc("/proxy", proxyHandler)
"regexp"
"strconv"
"strings"
+ "url"
)
// Takes a full file path and renames the last path component as if it were a
// Builds the URL to which we send a HTTP request to get the episode name.
func buildURL(info *episodeInfo) string {
return fmt.Sprintf("http://services.tvrage.com/tools/quickinfo.php?show=%s&ep=%dx%d",
- http.URLEscape(info.showName), info.season, info.episode)
+ url.QueryEscape(info.showName), info.season, info.episode)
}
// Converts a season and episode to integers. If the return values are both 0,
// Performs the actual lookup and returns the HTTP response.
func performLookup(urlString string) (*http.Response, os.Error) {
- url, err := http.ParseURL(urlString)
+ url_, err := url.Parse(urlString)
if err != nil {
return nil, err
}
// Open a TCP connection.
- conn, err := net.Dial("tcp", url.Host+":"+url.Scheme)
+ conn, err := net.Dial("tcp", url_.Host+":"+url_.Scheme)
if err != nil {
return nil, err
}
// Perform the HTTP request.
client := http.NewClientConn(conn, nil)
var request http.Request
- request.URL = url
+ request.URL = url_
request.Method = "GET"
- request.UserAgent = "Armadillo File Manager"
+ request.Header.Set("User-Agent", "Armadillo File Manager")
err = client.Write(&request)
if err != nil {
return nil, err
if err != nil {
return nil
}
- var parts []string = strings.Split(line, "@", 2)
+ var parts []string = strings.SplitN(line, "@", 2)
if len(parts) != 2 {
continue
}
info.episode.showName = strings.TrimSpace(parts[1])
case "Episode Info":
// Split the line, which is of the form: |SxE^Name^AirDate|.
- parts = strings.Split(parts[1], "^", 3)
+ parts = strings.SplitN(parts[1], "^", 3)
info.episodeName = parts[1]
// Split the episode string.
- episode := strings.Split(parts[0], "x", 2)
+ episode := strings.SplitN(parts[0], "x", 2)
info.episode.season, info.episode.episode = convertEpisode(episode[0], episode[1])
if info.episode.season == 0 && info.episode.season == info.episode.episode {
return nil