Browse Source

v0.2提交

罗俊辉 11 months ago
parent
commit
55a0c3dd38
100 changed files with 167 additions and 172 deletions
  1. 0 8
      LICENSE
  2. 2 1
      applications/__init__.py
  3. 28 35
      applications/aliyunLog.py
  4. 0 128
      auto_getoff_videos.py
  5. 4 0
      develop/change_status.py
  6. 13 0
      develop/read_logs.py
  7. 27 0
      develop/t.py
  8. 1 0
      static/21476565.json
  9. 1 0
      static/21476567.json
  10. 1 0
      static/21476568.json
  11. 1 0
      static/21477351.json
  12. 1 0
      static/21477356.json
  13. 1 0
      static/21477358.json
  14. 1 0
      static/21477360.json
  15. 1 0
      static/21477362.json
  16. 1 0
      static/21477371.json
  17. 1 0
      static/21477667.json
  18. 1 0
      static/21485672.json
  19. 1 0
      static/21485676.json
  20. 1 0
      static/21485684.json
  21. 1 0
      static/21486692.json
  22. 1 0
      static/21486713.json
  23. 1 0
      static/21486717.json
  24. 1 0
      static/21486744.json
  25. 1 0
      static/21486750.json
  26. 1 0
      static/21486758.json
  27. 1 0
      static/21487636.json
  28. 1 0
      static/21487641.json
  29. 1 0
      static/21487642.json
  30. 1 0
      static/21487643.json
  31. 1 0
      static/21487644.json
  32. 1 0
      static/21487647.json
  33. 1 0
      static/21487652.json
  34. 1 0
      static/21487655.json
  35. 1 0
      static/21487657.json
  36. 1 0
      static/21487660.json
  37. 1 0
      static/21487662.json
  38. 1 0
      static/21487663.json
  39. 1 0
      static/21487674.json
  40. 1 0
      static/21487675.json
  41. 1 0
      static/21487682.json
  42. 1 0
      static/21487976.json
  43. 1 0
      static/21487987.json
  44. 1 0
      static/21487993.json
  45. 1 0
      static/21488075.json
  46. 1 0
      static/21488076.json
  47. 1 0
      static/21488080.json
  48. 1 0
      static/21488082.json
  49. 1 0
      static/21488087.json
  50. 1 0
      static/21488088.json
  51. 1 0
      static/21488185.json
  52. 1 0
      static/21488188.json
  53. 1 0
      static/21488189.json
  54. 1 0
      static/21488194.json
  55. 1 0
      static/21488196.json
  56. 1 0
      static/21488202.json
  57. 1 0
      static/21488256.json
  58. 1 0
      static/21488259.json
  59. 1 0
      static/21488268.json
  60. 1 0
      static/21488270.json
  61. 1 0
      static/21488272.json
  62. 1 0
      static/21488274.json
  63. 1 0
      static/21489091.json
  64. 1 0
      static/21489097.json
  65. 1 0
      static/21489099.json
  66. 1 0
      static/21489358.json
  67. 1 0
      static/21489367.json
  68. 1 0
      static/21489377.json
  69. 1 0
      static/21489441.json
  70. 1 0
      static/21489490.json
  71. 1 0
      static/21489581.json
  72. 1 0
      static/21490018.json
  73. 1 0
      static/21490020.json
  74. 1 0
      static/21490021.json
  75. 1 0
      static/21490026.json
  76. 1 0
      static/21490027.json
  77. 1 0
      static/21490029.json
  78. 1 0
      static/21490195.json
  79. 1 0
      static/21490256.json
  80. 1 0
      static/21490257.json
  81. 1 0
      static/21490259.json
  82. 1 0
      static/21490263.json
  83. 1 0
      static/21490265.json
  84. 1 0
      static/21490278.json
  85. 1 0
      static/21490301.json
  86. 1 0
      static/21490302.json
  87. 1 0
      static/21491869.json
  88. 1 0
      static/21491876.json
  89. 1 0
      static/21491878.json
  90. 1 0
      static/21491881.json
  91. 1 0
      static/21491884.json
  92. 1 0
      static/21491886.json
  93. 1 0
      static/21491888.json
  94. 1 0
      static/21491891.json
  95. 1 0
      static/21491895.json
  96. 1 0
      static/21492060.json
  97. 1 0
      static/21492066.json
  98. 1 0
      static/21492075.json
  99. 1 0
      static/21492392.json
  100. 1 0
      static/21492397.json

+ 0 - 8
LICENSE

@@ -1,8 +0,0 @@
-MIT License
-Copyright (c) <year> <copyright holders>
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 2 - 1
applications/__init__.py

@@ -1,4 +1,5 @@
 """
 @author: luojunhui
 """
-from .aliyunLog import AliyunLog
+
+from .aliyunLog import read_log

+ 28 - 35
applications/aliyunLog.py

@@ -1,44 +1,37 @@
 """
 @author: luojunhui
 """
+import time
+
 from aliyun.log import LogClient, GetLogsRequest
 
+access_key_id = "LTAIP6x1l3DXfSxm"
+access_key_secret = "KbTaM9ars4OX3PMS6Xm7rtxGr1FLon"
+project = "wqsd-video"
+log_store = "video-action-log"
+endpoint = "cn-hangzhou.log.aliyuncs.com"
+
 
-class AliyunLog(object):
+def read_log(start_time, end_time, query, topic=""):
     """
-    Aliyun Log Class
+    :param topic:
+    :param start_time:
+    :param end_time:
+    :param query:
+    :return:
     """
-    access_key_id = 'LTAIP6x1l3DXfSxm'
-    access_key_secret = 'KbTaM9ars4OX3PMS6Xm7rtxGr1FLon'
-    project = 'wqsd-video'
-    log_store = 'video-action-log'
-    endpoint = "cn-hangzhou.log.aliyuncs.com"
-
-    # 初始化日志客户端
-    client = LogClient(endpoint, access_key_id, access_key_secret)
-
-    @classmethod
-    def get_log(cls, start_time, end_time, query, topic=''):
-        """
-        :param topic:
-        :param start_time:
-        :param end_time:
-        :param query:
-        :return:
-        """
-        request = GetLogsRequest(
-            cls.project,
-            cls.log_store,
-            start_time,
-            end_time,
-            topic,
-            query
-        )
-        response = cls.client.get_logs(request)
-        if response.get_count() > 0:
-            for log in response.get_logs():
-                print(log.log_print())
-                # for content in log.get_contents():
-                #     print(content)
+    request = GetLogsRequest(project, log_store, start_time, end_time, topic, query)
+    client = LogClient(
+        endpoint=endpoint, accessKeyId=access_key_id, accessKey=access_key_secret
+    )
+    response = client.get_logs(request)
+    if response.get_count() > 0:
+        log_list = response.get_logs()
+        sorted_log_list = sorted(log_list, key=lambda x: x.timestamp)
+        first_log = sorted_log_list[0]
+        if int(time.time()) - first_log.timestamp > 3 * 24 * 60 * 60:
+            return True
         else:
-            print("没有日志数据")
+            return False
+    else:
+        return False

+ 0 - 128
auto_getoff_videos.py

@@ -1,128 +0,0 @@
-"""
-@author: luojunhui
-"""
-import time
-
-import requests
-import pymysql
-import pandas as pd
-
-
-class AutoGetOffVideos(object):
-    """
-    自动下架视频
-    """
-
-    @classmethod
-    def get_long_articles_video_list(cls):
-        """
-        获取长文视频list
-        :return:
-        """
-        spider_connection = pymysql.connect(
-            host="rm-bp1159bu17li9hi94.mysql.rds.aliyuncs.com",
-            port=3306,
-            user="crawler",
-            passwd="crawler123456@",
-            db="piaoquan-crawler",
-            charset="utf8mb4"
-        )
-        now_time_stamp = int(time.time())
-        three_days_stamp = now_time_stamp - 3 * 24 * 60 * 60
-        seven_days_stamp = now_time_stamp - 7 * 24 * 60 * 60
-        select_sql = f"""
-        SELECT recall_video_id1, recall_video_id2, recall_video_id3 
-        FROM long_articles_video 
-        WHERE request_time_stamp > %s;
-        """
-        cursor = spider_connection.cursor()
-        cursor.execute(select_sql, seven_days_stamp)
-        data = cursor.fetchall()
-        vid_set = set()
-        for item in data:
-            for vid in item:
-                if vid:
-                    vid_set.add(vid)
-        return tuple(vid_set)
-
-    @classmethod
-    def find_video_play_count(cls, vid_tuple):
-        """
-        获取视频的播放次数
-        :return:
-        """
-        wx_video_connection = pymysql.connect(
-            host="rr-bp1x9785e8h5452bi157.mysql.rds.aliyuncs.com",
-            port=3306,
-            user="wx2016_longvideo",
-            passwd="wx2016_longvideoP@assword1234",
-            db="longvideo",
-            charset="utf8mb4"
-        )
-        sql = f"""select id, title, play_count, play_count_total from wx_video where id in {vid_tuple};"""
-        cursor = wx_video_connection.cursor()
-        cursor.execute(sql)
-        data = cursor.fetchall()
-        result = [
-            {
-                "video_id": item[0],
-                "title": item[1],
-                "play_count": item[2],
-                "play_total_count": item[3]
-            }
-            for item in data
-            ]
-        return result
-
-    @classmethod
-    def change_status(cls, video_id):
-        """
-        修改视频规则
-        :return:
-        """
-        url = "https://admin.piaoquantv.com/manager/video/audit/v2/updateAuditStatus"
-        params = {
-            "videoId": video_id,
-            "auditStatus": 2,
-            "updateReasonJson": "",
-            "rejectReasonJson": [
-                {
-                    "reason": "测试自动下架",
-                    "reasonId": -1
-                }
-            ],
-            "adminUid": 206
-
-        }
-        headers = {
-            'accept': 'application/json',
-            'accept-language': 'en,zh;q=0.9,zh-CN;q=0.8',
-            'content-type': 'application/x-www-form-urlencoded;charset=UTF-8',
-            'cookie': 'SESSION=NTljNTg2YjktMTU0MC00YWQ5LWE4ZTktNDFhODY0NzM3NTcx',
-            'origin': 'https://admin.piaoquantv.com',
-            'priority': 'u=1, i',
-            'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"',
-            'sec-ch-ua-mobile': '?0',
-            'sec-ch-ua-platform': '"macOS"',
-            'sec-fetch-dest': 'empty',
-            'sec-fetch-mode': 'cors',
-            'sec-fetch-site': 'same-origin',
-            'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36'
-        }
-        response = requests.request(
-            "POST",
-            url,
-            headers=headers,
-            params=params
-        )
-        return response.json()
-
-
-if __name__ == '__main__':
-    AGOV = AutoGetOffVideos()
-    vid_set = AGOV.get_long_articles_video_list()
-    result = AGOV.find_video_play_count(vid_set)
-    for i in result:
-        print(i)
-
-

+ 4 - 0
develop/change_status.py

@@ -0,0 +1,4 @@
+import os
+
+files = os.listdir("/Users/luojunhui/cyber/ScheduledTasks/static")
+print(len(files))

+ 13 - 0
develop/read_logs.py

@@ -0,0 +1,13 @@
+"""
+@author: luojunhui
+"""
+import time
+from applications import read_log
+
+end_time = int(time.time())
+start_time = end_time - 7 * 24 * 3600
+
+res = read_log(
+    start_time=start_time, end_time=end_time, query='businessType : videoPlay and videoId: 21923845'
+)
+print(res)

+ 27 - 0
develop/t.py

@@ -0,0 +1,27 @@
+"""
+@author: luojunhui
+"""
+import requests
+
+url = "https://admin.piaoquantv.com/manager/video/audit/v2/updateAuditStatus"
+
+payload = "videoId=21486692&auditStatus=2&updateReasonJson=&rejectReasonJson=%5B%7B%22reason%22%3A%22%E5%85%B6%E4%BB%96%22%2C%22reasonId%22%3A-1%7D%5D&adminUid=206"
+headers = {
+  'accept': 'application/json',
+  'accept-language': 'zh,zh-CN;q=0.9',
+  'content-type': 'application/x-www-form-urlencoded;charset=UTF-8',
+  'cookie': 'SESSION=YjIyYTIxOWUtYTAyNC00YTMxLWFiZGEtZmFlODY2MTVkOGYx',
+  'origin': 'https://admin.piaoquantv.com',
+  'priority': 'u=1, i',
+  'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"',
+  'sec-ch-ua-mobile': '?0',
+  'sec-ch-ua-platform': '"macOS"',
+  'sec-fetch-dest': 'empty',
+  'sec-fetch-mode': 'cors',
+  'sec-fetch-site': 'same-origin',
+  'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36'
+}
+
+response = requests.request("POST", url, headers=headers, data=payload)
+
+print(response.text)

+ 1 - 0
static/21476565.json

@@ -0,0 +1 @@
+{"time": 1719891651}

+ 1 - 0
static/21476567.json

@@ -0,0 +1 @@
+{"time": 1719891651}

+ 1 - 0
static/21476568.json

@@ -0,0 +1 @@
+{"time": 1719891652}

+ 1 - 0
static/21477351.json

@@ -0,0 +1 @@
+{"time": 1719891671}

+ 1 - 0
static/21477356.json

@@ -0,0 +1 @@
+{"time": 1719891671}

+ 1 - 0
static/21477358.json

@@ -0,0 +1 @@
+{"time": 1719891671}

+ 1 - 0
static/21477360.json

@@ -0,0 +1 @@
+{"time": 1719891671}

+ 1 - 0
static/21477362.json

@@ -0,0 +1 @@
+{"time": 1719891671}

+ 1 - 0
static/21477371.json

@@ -0,0 +1 @@
+{"time": 1719891672}

+ 1 - 0
static/21477667.json

@@ -0,0 +1 @@
+{"time": 1719891681}

+ 1 - 0
static/21485672.json

@@ -0,0 +1 @@
+{"time": 1719891676}

+ 1 - 0
static/21485676.json

@@ -0,0 +1 @@
+{"time": 1719891676}

+ 1 - 0
static/21485684.json

@@ -0,0 +1 @@
+{"time": 1719891676}

+ 1 - 0
static/21486692.json

@@ -0,0 +1 @@
+{"time": 1719891706}

+ 1 - 0
static/21486713.json

@@ -0,0 +1 @@
+{"time": 1719891706}

+ 1 - 0
static/21486717.json

@@ -0,0 +1 @@
+{"time": 1719891706}

+ 1 - 0
static/21486744.json

@@ -0,0 +1 @@
+{"time": 1719891707}

+ 1 - 0
static/21486750.json

@@ -0,0 +1 @@
+{"time": 1719891707}

+ 1 - 0
static/21486758.json

@@ -0,0 +1 @@
+{"time": 1719891707}

+ 1 - 0
static/21487636.json

@@ -0,0 +1 @@
+{"time": 1719891553}

+ 1 - 0
static/21487641.json

@@ -0,0 +1 @@
+{"time": 1719891553}

+ 1 - 0
static/21487642.json

@@ -0,0 +1 @@
+{"time": 1719891553}

+ 1 - 0
static/21487643.json

@@ -0,0 +1 @@
+{"time": 1719891553}

+ 1 - 0
static/21487644.json

@@ -0,0 +1 @@
+{"time": 1719891553}

+ 1 - 0
static/21487647.json

@@ -0,0 +1 @@
+{"time": 1719891553}

+ 1 - 0
static/21487652.json

@@ -0,0 +1 @@
+{"time": 1719891553}

+ 1 - 0
static/21487655.json

@@ -0,0 +1 @@
+{"time": 1719891553}

+ 1 - 0
static/21487657.json

@@ -0,0 +1 @@
+{"time": 1719891554}

+ 1 - 0
static/21487660.json

@@ -0,0 +1 @@
+{"time": 1719891554}

+ 1 - 0
static/21487662.json

@@ -0,0 +1 @@
+{"time": 1719891554}

+ 1 - 0
static/21487663.json

@@ -0,0 +1 @@
+{"time": 1719891554}

+ 1 - 0
static/21487674.json

@@ -0,0 +1 @@
+{"time": 1719891554}

+ 1 - 0
static/21487675.json

@@ -0,0 +1 @@
+{"time": 1719891554}

+ 1 - 0
static/21487682.json

@@ -0,0 +1 @@
+{"time": 1719891554}

+ 1 - 0
static/21487976.json

@@ -0,0 +1 @@
+{"time": 1719891560}

+ 1 - 0
static/21487987.json

@@ -0,0 +1 @@
+{"time": 1719891561}

+ 1 - 0
static/21487993.json

@@ -0,0 +1 @@
+{"time": 1719891561}

+ 1 - 0
static/21488075.json

@@ -0,0 +1 @@
+{"time": 1719891563}

+ 1 - 0
static/21488076.json

@@ -0,0 +1 @@
+{"time": 1719891563}

+ 1 - 0
static/21488080.json

@@ -0,0 +1 @@
+{"time": 1719891563}

+ 1 - 0
static/21488082.json

@@ -0,0 +1 @@
+{"time": 1719891563}

+ 1 - 0
static/21488087.json

@@ -0,0 +1 @@
+{"time": 1719891563}

+ 1 - 0
static/21488088.json

@@ -0,0 +1 @@
+{"time": 1719891563}

+ 1 - 0
static/21488185.json

@@ -0,0 +1 @@
+{"time": 1719891567}

+ 1 - 0
static/21488188.json

@@ -0,0 +1 @@
+{"time": 1719891567}

+ 1 - 0
static/21488189.json

@@ -0,0 +1 @@
+{"time": 1719891567}

+ 1 - 0
static/21488194.json

@@ -0,0 +1 @@
+{"time": 1719891567}

+ 1 - 0
static/21488196.json

@@ -0,0 +1 @@
+{"time": 1719891567}

+ 1 - 0
static/21488202.json

@@ -0,0 +1 @@
+{"time": 1719891567}

+ 1 - 0
static/21488256.json

@@ -0,0 +1 @@
+{"time": 1719891569}

+ 1 - 0
static/21488259.json

@@ -0,0 +1 @@
+{"time": 1719891570}

+ 1 - 0
static/21488268.json

@@ -0,0 +1 @@
+{"time": 1719891570}

+ 1 - 0
static/21488270.json

@@ -0,0 +1 @@
+{"time": 1719891570}

+ 1 - 0
static/21488272.json

@@ -0,0 +1 @@
+{"time": 1719891570}

+ 1 - 0
static/21488274.json

@@ -0,0 +1 @@
+{"time": 1719891570}

+ 1 - 0
static/21489091.json

@@ -0,0 +1 @@
+{"time": 1719891583}

+ 1 - 0
static/21489097.json

@@ -0,0 +1 @@
+{"time": 1719891583}

+ 1 - 0
static/21489099.json

@@ -0,0 +1 @@
+{"time": 1719891583}

+ 1 - 0
static/21489358.json

@@ -0,0 +1 @@
+{"time": 1719891592}

+ 1 - 0
static/21489367.json

@@ -0,0 +1 @@
+{"time": 1719891592}

+ 1 - 0
static/21489377.json

@@ -0,0 +1 @@
+{"time": 1719891593}

+ 1 - 0
static/21489441.json

@@ -0,0 +1 @@
+{"time": 1719891593}

+ 1 - 0
static/21489490.json

@@ -0,0 +1 @@
+{"time": 1719891594}

+ 1 - 0
static/21489581.json

@@ -0,0 +1 @@
+{"time": 1719891596}

+ 1 - 0
static/21490018.json

@@ -0,0 +1 @@
+{"time": 1719891604}

+ 1 - 0
static/21490020.json

@@ -0,0 +1 @@
+{"time": 1719891604}

+ 1 - 0
static/21490021.json

@@ -0,0 +1 @@
+{"time": 1719891604}

+ 1 - 0
static/21490026.json

@@ -0,0 +1 @@
+{"time": 1719891604}

+ 1 - 0
static/21490027.json

@@ -0,0 +1 @@
+{"time": 1719891604}

+ 1 - 0
static/21490029.json

@@ -0,0 +1 @@
+{"time": 1719891604}

+ 1 - 0
static/21490195.json

@@ -0,0 +1 @@
+{"time": 1719891606}

+ 1 - 0
static/21490256.json

@@ -0,0 +1 @@
+{"time": 1719891607}

+ 1 - 0
static/21490257.json

@@ -0,0 +1 @@
+{"time": 1719891607}

+ 1 - 0
static/21490259.json

@@ -0,0 +1 @@
+{"time": 1719891607}

+ 1 - 0
static/21490263.json

@@ -0,0 +1 @@
+{"time": 1719891607}

+ 1 - 0
static/21490265.json

@@ -0,0 +1 @@
+{"time": 1719891607}

+ 1 - 0
static/21490278.json

@@ -0,0 +1 @@
+{"time": 1719891607}

+ 1 - 0
static/21490301.json

@@ -0,0 +1 @@
+{"time": 1719891607}

+ 1 - 0
static/21490302.json

@@ -0,0 +1 @@
+{"time": 1719891607}

+ 1 - 0
static/21491869.json

@@ -0,0 +1 @@
+{"time": 1719891633}

+ 1 - 0
static/21491876.json

@@ -0,0 +1 @@
+{"time": 1719891632}

+ 1 - 0
static/21491878.json

@@ -0,0 +1 @@
+{"time": 1719891632}

+ 1 - 0
static/21491881.json

@@ -0,0 +1 @@
+{"time": 1719891633}

+ 1 - 0
static/21491884.json

@@ -0,0 +1 @@
+{"time": 1719891633}

+ 1 - 0
static/21491886.json

@@ -0,0 +1 @@
+{"time": 1719891634}

+ 1 - 0
static/21491888.json

@@ -0,0 +1 @@
+{"time": 1719891634}

+ 1 - 0
static/21491891.json

@@ -0,0 +1 @@
+{"time": 1719891634}

+ 1 - 0
static/21491895.json

@@ -0,0 +1 @@
+{"time": 1719891634}

+ 1 - 0
static/21492060.json

@@ -0,0 +1 @@
+{"time": 1719891637}

+ 1 - 0
static/21492066.json

@@ -0,0 +1 @@
+{"time": 1719891637}

+ 1 - 0
static/21492075.json

@@ -0,0 +1 @@
+{"time": 1719891637}

+ 1 - 0
static/21492392.json

@@ -0,0 +1 @@
+{"time": 1719891640}

+ 1 - 0
static/21492397.json

@@ -0,0 +1 @@
+{"time": 1719891640}

Some files were not shown because too many files changed in this diff