Storage.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. from collectSports.items import *
  2. import uuid
  3. class Storage(object):
  4. def __init__(self):
  5. pass
  6. def zaopan(self, re):
  7. data = CollectsportsItem()
  8. data['csource'] = 'zaopan'
  9. data['zq_league'] = data['zq_match'] = []
  10. for index in re['data']:
  11. i_uuid = uuid.uuid4()
  12. # print(i_uuid)
  13. lg = ZqLeagueItem()
  14. # lg['league_id'] = index['league_id']
  15. lg['league_name'] = index['league_name']
  16. lg['uuid'] = i_uuid
  17. # lg['source'] = 'hg0088'
  18. lg['content']={'league_id':index['league_id'],'source':'hg0088'}
  19. mc = ZqMatch()
  20. mc['match_id'] = index['match_id']
  21. mc['half_match_id'] = index['half_match_id']
  22. mc['host_id'] = index['host_id']
  23. mc['guest_id'] = index['guest_id']
  24. mc['host_name'] = index['host_name']
  25. mc['guest_name'] = index['guest_name']
  26. mc['is_half'] = 0
  27. mc['league_id'] = index['league_id']
  28. mc['is_roll'] = index['is_roll'] # 是否滚球
  29. mc['mdate'] = index['mdate']
  30. mc['mtime'] = index['mtime']
  31. mc['is_corner'] = index['is_corner']
  32. mc['uuid'] = i_uuid
  33. mc['source'] = 'hg0088'
  34. data['zq_match'].append(mc)
  35. mc['is_half'] = 1
  36. mc['match_id'] = index['half_match_id']
  37. mc['half_match_id'] = 0
  38. data['zq_match'].append(mc)
  39. data['zq_league'].append(lg)
  40. return data
  41. def zhibo(self, re):
  42. data = CollectsportsItem()
  43. data['csource'] = 'zhibo'
  44. data['zq_zhibo'] = []
  45. for index in re:
  46. lg = ZqZhibo()
  47. lg['game_type'] = index['game_type']
  48. lg['start_time'] = index['start_time']
  49. lg['host_team'] = index['host_team']
  50. lg['guest_team'] = index['guest_team']
  51. lg['doing'] = index['doing']
  52. lg['showid'] = index['showid']
  53. lg['shower'] = index['shower']
  54. lg['league_name'] = index['league_name']
  55. data['zq_zhibo'].append(lg)
  56. return data
  57. def chain(self, re):
  58. data = CollectsportsItem()
  59. data['csource'] = 'chain'
  60. data['zq_league'] = data['zq_chain'] = []
  61. for index in re:
  62. lg = ZqLeagueItem()
  63. lg['start_time'] = index['start_time']
  64. lg['league_id'] = index['league_id']
  65. lg['league_name'] = index['league_name']
  66. lg['league_subname'] = index['league_subname']
  67. lg['team_num'] = index['dcount']
  68. lg['game_type'] = index['game_type']
  69. for item in index['items']:
  70. mc = ZqChain()
  71. mc['league_id'] = index['league_id']
  72. mc['status'] = item['status']
  73. mc['code'] = item['code']
  74. mc['name'] = item['name']
  75. mc['enabled'] = item['enabled']
  76. mc['odds'] = item['odds']
  77. data['zq_chain'].append(mc)
  78. data['zq_league'].append(lg)
  79. return data
  80. def today(self, re):
  81. data = CollectsportsItem()
  82. data['csource'] = 'today'
  83. data['zq_today'] = []
  84. for index in re:
  85. lg = ZqToday()
  86. lg['match_id'] = index['match_id']
  87. lg['is_roll'] = index['is_roll']
  88. lg['is_corner'] = index['is_corner']
  89. data['zq_today'].append(lg)
  90. return data