示例#1
0
def downloadTrailer(trailerUrl, filePath):
    """ Download the specified trailer.
        @param trailerUrl: Trailer URL (ex: /trailer/the-terminal/trailer)
        @param filePath: Path to save trailer
    """
    videoHtml = util.getHtml(trailerUrl)
    videoId = re.findall(ID_REGEX, trailerUrl)[0][0]
    tParam = re.findall(T_PARAM_REGEX, videoHtml)[0]
    fileUrl = VIDEO_URL % (videoId, tParam)
    util.downloadFile(fileUrl, filePath)
示例#2
0
def downloadTrailer(trailerUrl, filePath):
    """ Download the specified trailer.
        @param trailerUrl: Trailer URL (ex: /trailer/the-terminal/trailer)
        @param filePath: Path to save trailer
    """
    trailerHtml = util.getHtml(trailerUrl)
    videoNumbers = re.findall(VIDEONUM_REGEX, trailerHtml)
    flashUrl = FLASH_URL.replace('{{videonum}}', videoNumbers[0])
    flashResponse = util.getHtml(flashUrl)
    fileUrl = re.findall(FLASH_REGEX, flashResponse)[0]
    util.downloadFile(fileUrl, filePath)
示例#3
0
def upgradeJaclang():
    print("Installing jaclang")

    # download archive
    version = "beta-" + newest_version.split(" ")[1]
    downloadFile(f"https://github.com/Zorz42/jaclang/archive/{version}.tar.gz",
                 f"{cachedir}newerjaclang.tar.gz")

    # extract archive
    extractTar(f"{cachedir}newerjaclang.tar.gz", cachedir)

    # install jaclang
    system(f"make -C {cachedir}jaclang-{version}")

    # cleanup
    remove(f"{cachedir}newerjaclang.tar.gz")
    rmtree(f"{cachedir}jaclang-{version}")
示例#4
0
 def startEvent2(self):
     for i in range(self.ui.downloadTable.rowCount()):
         if self.ui.downloadTable.item(i, 0).checkState() == QtCore.Qt.Checked:
             ans = downloadFile(self.downloader[i]['filename'], self.downloader[i]['Auth Token'], self.downloader[i]['StorageURL'], self.downloader[i]['container'])
             print 'ans' , ans
             if ans != 'forbidden':
                 self.ui.downloadTable.item(i, 3).setText('succeed')
             else :
                 QtGui.QMessageBox.information(self, 'Info', 'Sorry, you have no privieledge to download:\n\t' + self.downloader[i]['filename'],  QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
                 self.ui.downloadTable.item(i, 3).setText('denied')
示例#5
0
文件: install.py 项目: Zorz42/jpm
def installPackage(package_name: str):
    print(f"Installing {package_name}")

    info = loadInfo(f"{installdir}{package_name}.json")

    # download archive
    downloadFile(f"{main_repository}{package_name}/Versions/{info['Version']}.tar.gz", f"{libdir}{package_name}.tar.gz")

    # make directory for the package and extract it
    extractTar(f"{libdir}{package_name}.tar.gz", libdir + package_name, remove_tar=True)

    # replace optimized json file
    replace(f"{installdir}{package_name}.json", f"{libdir}{package_name}/Info.json")

    if not packageExists(package_name):
        printWarning(f"Package '{package_name}' does not seem to be valid.")

    # compile library
    system(f"{jacdir}Binaries/jacmake {libdir}{package_name}")
    rmtree(f"{libdir}{package_name}/Sources")
示例#6
0
def checkForJaclangUpgrade(check_anyways=False):
    makeCacheDir()
    # download jaclang version file if could connect to the internet

    # check if it is internet connection and if newestversion.txt was not updated in the last 24 hours
    if check_anyways or (
            not path.isfile(f"{cachedir}newestversion.txt")
            or time() - stat(f"{cachedir}newestversion.txt").st_ctime >= 86400
            and checkRepConnection()):
        downloadFile(
            "https://raw.githubusercontent.com/Zorz42/jaclang/master/Headers/version.h",
            f"{cachedir}newestversion.txt")

    # open version file
    with open(f"{cachedir}newestversion.txt") as newest_version_file:
        global newest_version
        # parse version file
        newest_version = "BETA " + ".".join([
            line.split(" ")[2][1:-1]
            for line in newest_version_file.read().split("\n") if line
        ])
        return newest_version != popen(
            f"{jacdir}Binaries/jaclang --version").read()[:-1]
示例#7
0
文件: install.py 项目: Zorz42/jpm
def buildDepTree(package_name: str, dependency=False):
    # check if file has already been processed (circular dependencies)
    if path.isfile(f"{installdir}{package_name}.json"):
        return

    # download info file
    try:
        downloadFile(f"{main_repository}{package_name}/Latest.json", f"{installdir}{package_name}.json")
    except HTTPError:
        raise DependencyError(f"Package '{package_name}' does not exist.")

    # load info file
    try:
        info = loadInfo(f"{installdir}{package_name}.json")
    except decoder.JSONDecodeError:
        raise DependencyError(f"Package '{package_name}' is damaged and therefore cannot be downloaded!")

    # verify info file
    if not verifyPackageJson(info, installed=False):
        raise DependencyError(f"Package '{package_name}' is incomplete and therefore cannot be downloaded!")

    # get current jaclang version and supported one
    supported_version = [int(x) for x in info["Supported Version"].split(".")]
    current_version = popen(f"{jacdir}Binaries/jaclang --version").read().split(" ")[1]
    current_version = [int(x) for x in current_version.split(".")[:-1]]

    # check if package supports current jaclang version
    if current_version[0] != supported_version[0] or current_version[1] < supported_version[1]:
        raise DependencyError(f"Package '{package_name}' is not compatible with your current version of jaclang!")

    del info["Supported Version"]
    info["Type"] = "Dependency" if dependency else "Package"

    for dependency_ in info["Dependencies"]:
        buildDepTree(dependency_, dependency=True)

    writeInfo(info, f"{installdir}{package_name}.json")
示例#8
0
 def startEvent2(self):
     for i in range(self.ui.downloadTable.rowCount()):
         if self.ui.downloadTable.item(i,
                                       0).checkState() == QtCore.Qt.Checked:
             ans = downloadFile(self.downloader[i]['filename'],
                                self.downloader[i]['Auth Token'],
                                self.downloader[i]['StorageURL'],
                                self.downloader[i]['container'])
             print 'ans', ans
             if ans != 'forbidden':
                 self.ui.downloadTable.item(i, 3).setText('succeed')
             else:
                 QtGui.QMessageBox.information(
                     self, 'Info',
                     'Sorry, you have no privieledge to download:\n\t' +
                     self.downloader[i]['filename'], QtGui.QMessageBox.Yes,
                     QtGui.QMessageBox.No)
                 self.ui.downloadTable.item(i, 3).setText('denied')
示例#9
0
        else:
            print('The required Forge version has not been detected on your system.')
            message = 'install'
        # Ask the user whether or not they need Forge.
        if util.query_yes_no('Do you need to {} Forge?'.format(message), default='no'):
            forge = util.MODS['mods']['forge']
            name = forge['name']
            version = forge['version']
            jarName = 'forge.jar'

            if sys.platform == 'win32' or sys.platform == 'cygwin':
                os.chdir(BASE_DIR)

            # Download the Forge installer.
            print('Downloading {} version {}'.format(name, version))
            util.downloadFile(forge['url'], jarName)

            if sys.platform == 'win32' or sys.platform == 'cygwin':
                print('You must now run the {} that has been downloaded to your Launchcraft directory.'.format(jarName))
                util.exit()
            else:
                # Run the installer so the user can install Forge.
                print('You will now be asked to install Forge version {}.'.format(version))
                with open(os.devnull, 'w') as devnull:
                    subprocess.call('java -jar {}'.format(jarName), shell=True, stdout=devnull)

                os.remove(jarName)
    util.print_separator()

    JAR_FILE = os.path.join(PROFILE_DIR, '{}.jar'.format(profile_name))
    JSON_FILE = os.path.join(PROFILE_DIR, '{}.json'.format(profile_name))
示例#10
0
                for aSet in mpd_.adaptionSetLst:
                    if aSet.contentType == "audio" and aSet.widevineContentProtection and aSet.playReadyContentProtection:
                        wv = aSet.widevineContentProtection.cencPsshData
                        pr = aSet.playReadyContentProtection.cencPsshData
                        cencInitData = util.buildWidevineInitDataString(None, cencInitDataWv=wv, cencInitDataPr=pr)
                        provider.requestLicenseForEstablishedSession(amazonUrlOrAsin, cencInitData)
            """
            selectedVideoRepresentation, selectedAudioRepresentation = \
                selectVideoAndAudio(mpd_, width=width, height=height, audioAdaptionSetIndex=audioAdaptionSetIndex,
                                    audioIndex=audioIndex, videoIndex=videoIndex)
            videoFileUrl = selectedVideoRepresentation.mediaFileUrl
            audioFileUrl = selectedAudioRepresentation.mediaFileUrl

            if options.saveRemoteFile:
                if options.saveRemoteFile == "a":
                    saveDataIntoFile(downloadFile(audioFileUrl), "audio.mp4")
                elif options.saveRemoteFile == "v":
                    saveDataIntoFile(downloadFile(videoFileUrl), "video.mp4")
                elif options.saveRemoteFile == "b":
                    saveDataIntoFile(downloadFile(audioFileUrl), "audio.mp4")
                    saveDataIntoFile(downloadFile(videoFileUrl), "video.mp4")
                else:
                    LOG.error("Save Remote file option %s unkown." %
                              options.saveRemoteFile)
                    sys.exit(1)
                sys.exit(0)

            # download InitRange
            videoInitData = downloadByteRange(
                videoFileUrl,
                selectedVideoRepresentation.segmentList.initRange)