fxg4758 Posted January 16, 2018 Share Posted January 16, 2018 Hi. Is possible get a url off the video from this site using Autoit? I can see the url when i use the Firefox and the extension HLS Stream Detector, but i need to made this process more fast without open the Firefox and copy the url by hand. I try to download by InetGet, but no lucky. Regards. https://goo.gl/LtY1rX Link to comment Share on other sites More sharing options...
Earthshine Posted January 17, 2018 Share Posted January 17, 2018 what have you tried so far? can you share it with us? it may still involve a browser on that page of course you understand. My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
fxg4758 Posted January 17, 2018 Author Share Posted January 17, 2018 6 hours ago, Earthshine said: what have you tried so far? can you share it with us? it may still involve a browser on that page of course you understand. Hi. My problem is that site and another that i use, they don´t show a diret link to a file. But, when i use the HLS Stream detector it can detect the correct url of the file in the page. Here is the code that addon use. Can someone tell me if is possible to export to Autoit only the function that detect the link of the file? In the site that i put previous, the link of file is this: https://goo.gl/QV48ZH Regards. expandcollapse popupvar self = require("sdk/self"); var { when: unload } = require("sdk/system/unload"); var { Cc, Ci } = require("chrome"); var { ActionButton } = require("sdk/ui/button/action"); var cm = require("sdk/context-menu"); var clipboard = require("sdk/clipboard"); var notifications = require("sdk/notifications"); var preferences = require("sdk/simple-prefs").prefs; var _ = require("sdk/l10n").get; var urlsdk = require("sdk/url"); var Request = require("sdk/request").Request; var system = require("sdk/system"); var notifIcon = self.data.url("icon-64.png"); var cookieGlob = -1; var referrerGlob = -1; var ua = -1; var urllist = []; //clipboard.set("osmfhls.kutu.ru"); //testing var httpRequestObserver = { observe: function (subject, topic, data) { var httpChannel = subject.QueryInterface(Ci.nsIHttpChannel); const httpproto = Cc["@mozilla.org/network/protocol;1?name=http"].getService(Ci.nsIHttpProtocolHandler); ua = httpproto.userAgent; //get user agent var url = httpChannel.URI.spec; //do stuff only if it's an m3u8 file and its url doesn't already exist on the urllist if (topic === "http-on-modify-request" && (url.indexOf(".m3u8?") != -1 || url.search(/\.m3u8$/i) != -1) && urllist.indexOf(url) === -1) { urllist.push(url); //add url to list of urls button.disabled = false; button.badgeColor = "#C00000"; //change badge color when something is found //not sure why this trainwreck segment works but it does try { var referrer = httpChannel.getRequestHeader("referer"); } catch (e) { var referrer = -1; } if (referrerGlob === -1 && referrer != -1) { referrerGlob = referrer; } try { var cookie = httpChannel.getRequestHeader("cookie"); } catch (e) { var cookie = -1; } if (cookieGlob === -1 && cookie != -1) { cookieGlob = cookie; } if (cookie === -1 && referrer === referrerGlob) { var cookie = cookieGlob; } var labelName = getFileName(url) + '.m3u8' + ' - ' + urlsdk.URL(url).host; //nice-looking menu entries function copyStuff() { if (preferences["copymethod"] != "url" && preferences["outdirloc"]) { if (preferences["copymethod"] === "ffmpeg") { if (preferences["ffmpegloc"] && !preferences["pathpref"]) { command = '"' + preferences["ffmpegloc"] + '"'; //beginning of ffmpeg command } else { command = "ffmpeg"; //when path not specified } if (preferences["headerspref"] === true && preferences["copymethod"] === "ffmpeg") { //only if headers checkbox is marked command = command + ' -user_agent "' + ua + '"'; if (cookie != -1) { //only if cookies were found in the trainwreck segment command = command + ' -headers "Cookie: ' + cookie + '"'; } } if (system.platform === "winnt") { if (preferences["outdirloc"] && !preferences["outpathpref"]) { command = command + ' -i "' + url + '" -c copy "' + preferences["outdirloc"] + '\\' + getFileName(url) + '.ts"' //add final part of command } else { command = command + ' -i "' + url + '" -c copy "' + getFileName(url) + '.ts"' //add final part of command } } else { if (preferences["outdirloc"] && !preferences["outpathpref"]) { command = command + ' -i "' + url + '" -c copy "' + preferences["outdirloc"] + '/' + getFileName(url) + '.ts"' //add final part of command } else { command = command + ' -i "' + url + '" -c copy "' + getFileName(url) + '.ts"' //add final part of command } } clipboard.set(command); if (preferences["notifpref"] === false) { notifications.notify({ title: _("notifcopiedtitle"), iconURL: notifIcon, text: _("notifcopiedtext") }); } } else if (preferences["copymethod"] === "livestreamer") { //livestreamer command if (preferences["livestreamerloc"] && !preferences["pathpref"]) { command = '"' + preferences["livestreamerloc"] + '"'; } else { command = "livestreamer"; } if (preferences["headerspref"] === true && preferences["copymethod"] === "livestreamer") { //only if headers checkbox is marked command = command + ' --http-header "User-Agent=' + ua + '"'; if (cookie != -1) { command = command + ' --http-cookie "' + cookie + '"'; } } if (cookie != -1) { //check type of file. messy Request({ url: url, headers: { "User-Agent": ua, "Cookie": cookie }, onComplete: function (response) { if (response.text.indexOf("EXT-X-STREAM-INF") != -1) { if (system.platform === "winnt") { command = command + ' -o "' + preferences["outdirloc"] + '\\' + getFileName(url) + '.ts" "hlsvariant://' + url + '" best'; } else { command = command + ' -o "' + preferences["outdirloc"] + '/' + getFileName(url) + '.ts" "hlsvariant://' + url + '" best'; } clipboard.set(command); } else { if (system.platform === "winnt") { command = command + ' -o "' + preferences["outdirloc"] + '\\' + getFileName(url) + '.ts" "hls://' + url + '" best'; } else { command = command + ' -o "' + preferences["outdirloc"] + '/' + getFileName(url) + '.ts" "hls://' + url + '" best'; } clipboard.set(command); } } }).get(); } else { Request({ url: url, headers: { "User-Agent": ua }, onComplete: function (response) { if (response.text.indexOf("EXT-X-STREAM-INF") != -1) { if (system.platform === "winnt") { command = command + ' -o "' + preferences["outdirloc"] + '\\' + getFileName(url) + '.ts" "hlsvariant://' + url + '" best'; } else { command = command + ' -o "' + preferences["outdirloc"] + '/' + getFileName(url) + '.ts" "hlsvariant://' + url + '" best'; } clipboard.set(command); } else { if (system.platform === "winnt") { command = command + ' -o "' + preferences["outdirloc"] + '\\' + getFileName(url) + '.ts" "hls://' + url + '" best'; } else { command = command + ' -o "' + preferences["outdirloc"] + '/' + getFileName(url) + '.ts" "hls://' + url + '" best'; } clipboard.set(command); } } }).get(); } if (preferences["notifpref"] === false) { notifications.notify({ title: _("notifcopiedtitle"), iconURL: notifIcon, text: _("notifcopiedtext") }); } } else { if (preferences["notifpref"] === false) { notifications.notify({ title: _("notiflocerrortitle"), iconURL: notifIcon, text: _("notiflocerrortext") }); } } } else if (preferences["copymethod"] != "url" && !preferences["outdirloc"]) { if (preferences["notifpref"] === false) { notifications.notify({ title: _("notiflocerrortitle"), iconURL: notifIcon, text: _("notiflocerrortext") }); } } else if (preferences["copymethod"] === "url") { clipboard.set(url); //otherwise copy url only if (preferences["notifpref"] === false) { notifications.notify({ title: _("notifcopiedtitle"), iconURL: notifIcon, text: _("notifcopiedtext") }); } } } m3u8menu.addItem(cm.Item({ //add menu entry label: labelName, contentScript: 'self.on("click", self.postMessage);', onMessage: copyStuff })); button.badge = button.badge + 1; //counter if (preferences["notifpref"] === false) { notifications.notify({ //notify and then do stuff similar to the context menu entries title: _("notiftitle"), iconURL: notifIcon, text: _("notiftext") + url, onClick: copyStuff }); } button.label = _("buttonlabelfound") + urllist.join("\n"); }; }, get observerService() { return Cc["@mozilla.org/observer-service;1"] .getService(Ci.nsIObserverService); }, register: function () { this.observerService.addObserver(this, "http-on-modify-request", false); //monitor http requests only }, unregister: function () { this.observerService.removeObserver(this, "http-on-modify-request"); } }; function getFileName(url) { //snip away everything except for the filename var filename = url; filename = filename.substring(0, (filename.indexOf("#") === -1) ? filename.length : filename.lastIndexOf("#")); filename = filename.substring(0, (filename.indexOf("?") === -1) ? filename.length : filename.lastIndexOf("?")); filename = filename.substring(0, (filename.indexOf(".") === -1) ? filename.length : filename.lastIndexOf(".")); filename = filename.substring(filename.lastIndexOf("/") + 1, filename.length); return filename; } var button = ActionButton({ //the toolbar button id: "m3u8button", label: _("buttonlabelempty"), icon: { "16": "./icon-16.png", "64": "./icon-64.png" }, onClick: handleClick, badge: 0, badgeColor: "#797C80", disabled: true }); function handleClick(state) { //reset counter, url list, global vars, badge, context menu urllist = []; button.badgeColor = "#797C80"; button.label = _("buttonlabelempty"); button.disabled = true; button.badge = 0; m3u8menu.items = []; cookieGlob = -1; referrerGlob = -1; } var m3u8menu = cm.Menu({ //main context menu label label: _("menulabel") }); //start observer httpRequestObserver.register(); //don't do things when off unload(function () { httpRequestObserver.unregister(); }); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now