示例#1
0
def ajaxGetLatestTorrent():
    releaseInfo = ReleaseInfo()
    releaseInfo.Logger = MyGlobals.Logger
    JobCommon.GetPtpOrImdbId(releaseInfo, request.values.get("PtpOrImdbLink"))

    torrentId = 0
    uploadedAgo = ""

    if not releaseInfo.IsZeroImdbId():
        Ptp.Login()

        movieOnPtpResult = None
        if releaseInfo.HasPtpId():
            movieOnPtpResult = Ptp.GetMoviePageOnPtp(releaseInfo.Logger,
                                                     releaseInfo.GetPtpId())
        else:
            movieOnPtpResult = Ptp.GetMoviePageOnPtpByImdbId(
                releaseInfo.Logger, releaseInfo.GetImdbId())

        if movieOnPtpResult:
            torrent = movieOnPtpResult.GetLatestTorrent()
            if torrent:
                torrentId = torrent.TorrentId

                difference = datetime.utcnow(
                ) - torrent.GetUploadTimeAsDateTimeUtc()
                uploadedAgo = "(Latest torrent uploaded: " + TimeDifferenceToText(
                    difference).lower() + ")"

    return jsonify(Result="OK", TorrentId=torrentId, UploadedAgo=uploadedAgo)
示例#2
0
    def __CheckIfExistsOnPtp(self):
        # TODO: this is temporary here. We should support it everywhere.
        # If we are not logged in here that could mean that the download took a lot of time and the user got logged out for some reason.
        Ptp.Login()

        # This could be before the Ptp.Login() line, but this way we can hopefully avoid some logging out errors.
        if self.ReleaseInfo.IsZeroImdbId():
            self.ReleaseInfo.Logger.info(
                "IMDb ID is set zero, ignoring the check for existing release."
            )
            return

        movieOnPtpResult = None

        if self.ReleaseInfo.HasPtpId():
            movieOnPtpResult = Ptp.GetMoviePageOnPtp(
                self.ReleaseInfo.Logger, self.ReleaseInfo.GetPtpId())
        else:
            movieOnPtpResult = Ptp.GetMoviePageOnPtpByImdbId(
                self.ReleaseInfo.Logger, self.ReleaseInfo.GetImdbId())
            self.ReleaseInfo.PtpId = movieOnPtpResult.PtpId

        # Check (again) if is it already on PTP.
        existingRelease = movieOnPtpResult.IsReleaseExists(self.ReleaseInfo)
        if existingRelease is not None:
            raise PtpUploaderException(
                JobRunningState.DownloadedAlreadyExists,
                "Got uploaded to PTP while we were working on it. Skipping upload because of format '%s'."
                % existingRelease)
示例#3
0
文件: Notifier.py 项目: Aniverse/p1
def Notify(releaseName, uploadedTorrentUrl):
    logger = MyGlobals.Logger

    userId = LoadNotifierSettings()
    userId = userId.strip()
    if not userId.isdigit():
        return

    Ptp.Login()
    subject = "[PtpUploader] %s" % releaseName
    message = "This is an automatic notification about a new [url=%s]upload[/url]." % uploadedTorrentUrl
    Ptp.SendPrivateMessage(userId, subject, message)
示例#4
0
def movieAvailabilityCheck():
	if request.method == 'POST':
		Ptp.Login()

		releaseInfo = ReleaseInfo()
		anyFormat = False

		format = request.values[ "format" ]
		if format == "Any":
			anyFormat = True
		elif format == "SD XviD":
			releaseInfo.Codec = "XviD"
			releaseInfo.Container = "AVI"
			releaseInfo.ResolutionType = "Other"
			releaseInfo.Source = "DVD"
		elif format == "SD x264":
			releaseInfo.Codec = "x264"
			releaseInfo.Container = "MKV"
			releaseInfo.ResolutionType = "Other"
			releaseInfo.Source = "DVD"
		elif format == "720p":
			releaseInfo.Codec = "x264"
			releaseInfo.Container = "MKV"
			releaseInfo.ResolutionType = "720p"
			releaseInfo.Source = "Blu-ray"
		elif format == "1080p":
			releaseInfo.Codec = "x264"
			releaseInfo.Container = "MKV"
			releaseInfo.ResolutionType = "1080p"
			releaseInfo.Source = "Blu-ray"
		elif format == "4K":
			releaseInfo.Codec = "x264"
			releaseInfo.Container = "MKV"
			releaseInfo.ResolutionType = "4K"
			releaseInfo.Source = "Blu-ray"
		else:
			return "Unknown format!"

		imdbIds = request.values[ "imdb" ]
		
		resultHtml = ""

		matches = re.findall( r"imdb.com/title/tt(\d+)", imdbIds )
		for match in matches:
			ptpId = GetPtpIdIfExists( match, releaseInfo, anyFormat )

			if ptpId is None:
				resultHtml += """<a href="http://www.imdb.com/title/tt%s">%s</a> - NOT ON PTP</br>""" % ( match, match )
			else:
				resultHtml += """<a href="http://www.imdb.com/title/tt%s">%s</a> - <a href="https://passthepopcorn.me/torrents.php?id=%s">PTP</a></br>""" % ( match, match, ptpId )
			
		return resultHtml

	return render_template( "movieAvailabilityCheck.html" )
示例#5
0
    def __LoadmdbInfo(self):
        # Already loaded
        if self.JsonMovie is not None:
            return

        # Get IMDb info through PTP's ajax API used by the site when the user presses the auto fill button.
        result = MyGlobals.session.get(
            "https://passthepopcorn.me/ajax.php?action=torrent_info&imdb=%s" %
            Ptp.NormalizeImdbIdForPtp(self.ImdbId))
        self.JsonResponse = result.text
        Ptp.CheckIfLoggedInFromResponse(result, self.JsonResponse)

        # The response is JSON.
        # [{"title":"Devil's Playground","plot":"As the world succumbs to a zombie apocalypse, Cole a hardened mercenary, is chasing the one person who can provide a cure. Not only to the plague but to Cole's own incumbent destiny. DEVIL'S PLAYGROUND is a cutting edge British horror film that features zombies portrayed by free runners for a terrifyingly authentic representation of the undead","art":false,"year":"2010","director":[{"imdb":"1654324","name":"Mark McQueen","role":null}],"tags":"action, horror","writers":[{"imdb":"1057010","name":"Bart Ruspoli","role":" screenplay"}]}]

        jsonResult = json.loads(self.JsonResponse)
        if len(jsonResult) != 1:
            raise PtpUploaderException(
                "Bad PTP movie info JSON response: array length is not one.\nFull response:\n%s"
                % self.JsonResponse)

        self.JsonMovie = jsonResult[0]
示例#6
0
def GetPtpIdIfExists(imdbId, releaseInfo, anyFormat):
    movieOnPtpResult = Ptp.GetMoviePageOnPtpByImdbId(MyGlobals.Logger, imdbId)
    exists = False

    if anyFormat:
        exists = movieOnPtpResult.IsMoviePageExists()
    else:
        exists = movieOnPtpResult.IsReleaseExists(releaseInfo) is not None

    if exists:
        return movieOnPtpResult.PtpId
    else:
        return None
    def __CheckIfExistsOnPtp(self):
        # TODO: this is temporary here. We should support it everywhere.
        # If we are not logged in here that could mean that nothing interesting has been announcened for a while.
        Ptp.Login()

        # This could be before the Ptp.Login() line, but this way we can hopefully avoid some logging out errors.
        if self.ReleaseInfo.IsZeroImdbId():
            self.ReleaseInfo.Logger.info(
                "IMDb ID is set zero, ignoring the check for existing release."
            )
            return

        movieOnPtpResult = None

        if self.ReleaseInfo.HasPtpId():
            movieOnPtpResult = Ptp.GetMoviePageOnPtp(
                self.ReleaseInfo.Logger, self.ReleaseInfo.GetPtpId())

            # If IMDb ID is not set, then store it, because it is needed for renaming releases coming from Cinemageddon and Cinematik.
            if (not self.ReleaseInfo.HasImdbId()) and len(
                    movieOnPtpResult.ImdbId) > 0:
                self.ReleaseInfo.ImdbId = movieOnPtpResult.ImdbId
        else:
            # Try to get a PTP ID.
            movieOnPtpResult = Ptp.GetMoviePageOnPtpByImdbId(
                self.ReleaseInfo.Logger, self.ReleaseInfo.GetImdbId())
            self.ReleaseInfo.PtpId = movieOnPtpResult.PtpId

        existingRelease = movieOnPtpResult.IsReleaseExists(self.ReleaseInfo)
        if existingRelease is not None:
            raise PtpUploaderException(
                JobRunningState.Ignored_AlreadyExists,
                "Already exists on PTP: '%s'." % existingRelease)

        self.ReleaseInfo.ImdbRating = movieOnPtpResult.ImdbRating
        self.ReleaseInfo.ImdbVoteCount = movieOnPtpResult.ImdbVoteCount
示例#8
0
    def __UploadMovie(self):
        # This is not possible because finished jobs can't be restarted.
        if self.ReleaseInfo.IsJobPhaseFinished(
                FinishedJobPhase.Upload_UploadMovie):
            self.ReleaseInfo.Logger.info(
                "Upload movie phase has been reached previously, not uploading it again."
            )
            return

        Ptp.UploadMovie(self.ReleaseInfo.Logger, self.ReleaseInfo,
                        self.ReleaseInfo.UploadTorrentFilePath,
                        self.ReleaseDescription)

        # Delete the source torrent file.
        if self.ReleaseInfo.IsSourceTorrentFilePathSet() and os.path.isfile(
                self.ReleaseInfo.SourceTorrentFilePath):
            os.remove(self.ReleaseInfo.SourceTorrentFilePath)
            self.ReleaseInfo.SourceTorrentFilePath = ""

        # Delete the uploaded torrent file.
        if self.ReleaseInfo.IsUploadTorrentFilePathSet() and os.path.isfile(
                self.ReleaseInfo.UploadTorrentFilePath):
            os.remove(self.ReleaseInfo.UploadTorrentFilePath)
            self.ReleaseInfo.UploadTorrentFilePath = ""

        jobDuration = TimeDifferenceToText(
            datetime.datetime.utcnow() - self.ReleaseInfo.JobStartTimeUtc, 10,
            "", "0s")
        self.ReleaseInfo.Logger.info(
            "'%s' has been successfully uploaded to PTP. Time taken: %s." %
            (self.ReleaseInfo.ReleaseName, jobDuration))

        self.ReleaseInfo.SetJobPhaseFinished(
            FinishedJobPhase.Upload_UploadMovie)
        self.ReleaseInfo.JobRunningState = JobRunningState.Finished
        Database.DbSession.commit()