示例#1
0
文件: tiktok.py 项目: rabea98/TikTok
    def get_videos(self):
        logging.info("Getting Videos...")
        videos = []
        db = os.path.join(self.internal_cache_path, "databases", "video.db")

        database = Database(db)
        results = database.execute_query(
            "select key, extra from video_http_header_t")

        for entry in results:
            video = {}
            video["key"] = entry[0]
            dump = json.loads(entry[1])

            for line in dump["responseHeaders"].splitlines():
                if 'Last-Modified:' in line:
                    video["last_modified"] = Utils.date_parser(
                        line.split(": ")[1], "%a, %d %b %Y %H:%M:%S %Z")

                    timeline_event = {}
                    timeline_event["video"] = video["key"]

                    self.timeline.add(video["last_modified"], "video",
                                      timeline_event)
                    break
            self.media.add(
                os.path.join("internal", "cache", "cache", video["key"]))
            videos.append(video)

        logging.info("{} video(s) found".format(len(videos)))
        return videos
示例#2
0
    def get_last_session(self):
        logging.info("Getting last session...")
        session = []

        relevant_keys = [
            "device", "name", "status", "ab_sdk_version",
            "storage_available_internal_size",
            "storage_available_external_size", "app_storage_size", "brand",
            "page", "request_method", "is_first", "duration", "is_first",
            "rip", "duration", "author_id", "access2", "video_duration",
            "video_quality", "access", "page_uid", "previous_page",
            "enter_method", "enter_page", "key_word", "search_keyword",
            "next_tab", "search_type", "play_duration", "content",
            "manufacturer", "os_version"
        ]

        db = os.path.join(self.internal_cache_path, "databases",
                          "ss_app_log.db")
        database = Database(db)
        results = database.execute_query(
            "select tag, ext_json, datetime(timestamp/1000, 'unixepoch', 'localtime'), session_id from event order by timestamp"
        )

        for entry in results:
            session_entry = {}
            session_entry["action"] = entry[0]

            body_dump = json.loads(entry[1])
            session_entry["time"] = Utils.date_parser(entry[2],
                                                      "%Y-%m-%d %H:%M:%S")
            session_entry["session_id"] = entry[3]

            timeline_event = {}
            timeline_event["action"] = session_entry["action"]

            self.timeline.add(session_entry["time"], "AF_system",
                              timeline_event)

            session.append(session_entry)

            #json body parser
            body = {}
            for key, value in body_dump.items():
                if key in relevant_keys:
                    body[key] = value

            session_entry["body"] = body

        logging.info("{} entrys found".format(len(results)))
        return session