Storage.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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'] = []
  10. data['zq_match'] = []
  11. for index in re['data']:
  12. lg = ZqLeagueItem()
  13. content = []
  14. content.append({'league_id': index['league_id'], 'source': 'hg0088'})
  15. i_uuid = uuid.uuid4()
  16. lg['uuid'] = i_uuid
  17. lg['league_id'] = index['league_id']
  18. lg['league_name'] = index['league_name']
  19. lg['content'] = content
  20. mc = ZqMatch()
  21. mc['match_id'] = index['match_id']
  22. mc['half_match_id'] = index['half_match_id']
  23. mc['host_id'] = index['host_id']
  24. mc['guest_id'] = index['guest_id']
  25. mc['host_name'] = index['host_name']
  26. mc['guest_name'] = index['guest_name']
  27. mc['is_half'] = 0
  28. mc['league_id'] = index['league_id']
  29. mc['is_roll'] = index['is_roll'] # 是否滚球
  30. mc['mdate'] = index['mdate']
  31. mc['mtime'] = index['mtime']
  32. mc['is_corner'] = index['is_corner']
  33. mc['uuid'] = i_uuid
  34. mc_half = ZqMatch()
  35. if index['half_match_id']:
  36. mc_half['match_id'] = index['half_match_id']
  37. # else:
  38. # mc_half['match_id'] = index['match_id']
  39. mc_half['half_match_id'] = 0
  40. mc_half['host_id'] = index['host_id']
  41. mc_half['guest_id'] = index['guest_id']
  42. mc_half['host_name'] = index['host_name']
  43. mc_half['guest_name'] = index['guest_name']
  44. mc_half['is_half'] = 1
  45. mc_half['league_id'] = index['league_id']
  46. mc_half['is_roll'] = index['is_roll'] # 是否滚球
  47. mc_half['mdate'] = index['mdate']
  48. mc_half['mtime'] = index['mtime']
  49. mc_half['is_corner'] = index['is_corner']
  50. mc_half['uuid'] = i_uuid
  51. data['zq_match'].append(mc_half)
  52. data['zq_league'].append(lg)
  53. data['zq_match'].append(mc)
  54. return data
  55. def zhibo(self, re):
  56. data = CollectsportsItem()
  57. data['csource'] = 'zhibo'
  58. data['zq_zhibo'] = []
  59. for index in re:
  60. lg = ZqZhibo()
  61. lg['game_type'] = index['game_type']
  62. lg['start_time'] = index['start_time']
  63. lg['host_team'] = index['host_team']
  64. lg['guest_team'] = index['guest_team']
  65. lg['doing'] = index['doing']
  66. lg['showid'] = index['showid']
  67. lg['shower'] = index['shower']
  68. lg['league_name'] = index['league_name']
  69. data['zq_zhibo'].append(lg)
  70. return data
  71. def chain(self, re):
  72. data = CollectsportsItem()
  73. data['csource'] = 'chain'
  74. data['zq_league'] = data['zq_chain'] = []
  75. for index in re:
  76. lg = ZqLeagueItem()
  77. lg['start_time'] = index['start_time']
  78. lg['league_id'] = index['league_id']
  79. lg['league_name'] = index['league_name']
  80. lg['league_subname'] = index['league_subname']
  81. lg['team_num'] = index['dcount']
  82. lg['game_type'] = index['game_type']
  83. for item in index['items']:
  84. mc = ZqChain()
  85. mc['league_id'] = index['league_id']
  86. mc['status'] = item['status']
  87. mc['code'] = item['code']
  88. mc['name'] = item['name']
  89. mc['enabled'] = item['enabled']
  90. mc['odds'] = item['odds']
  91. data['zq_chain'].append(mc)
  92. data['zq_league'].append(lg)
  93. return data
  94. def today(self, re):
  95. data = CollectsportsItem()
  96. data['csource'] = 'today'
  97. data['zq_today'] = []
  98. for index in re:
  99. lg = ZqToday()
  100. lg['match_id'] = index['match_id']
  101. lg['is_roll'] = index['is_roll']
  102. lg['is_corner'] = index['is_corner']
  103. data['zq_today'].append(lg)
  104. return data